package com.kkd.kkdapp.utils;

import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

import pl.droidsonroids.gif.GifDrawable;
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnKeyListener;
import android.content.DialogInterface.OnShowListener;
import android.content.Intent;
import android.content.res.Resources.NotFoundException;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.text.Editable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.ForegroundColorSpan;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.ScaleAnimation;
import android.webkit.SslErrorHandler;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.PopupWindow.OnDismissListener;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.google.gson.Gson;
import com.kkd.kkdapp.R;
import com.kkd.kkdapp.Notify.Const;
import com.kkd.kkdapp.Notify.NotifyDispatcher;
import com.kkd.kkdapp.activity.HomeActivity;
import com.kkd.kkdapp.activity.KKDWebActivity;
import com.kkd.kkdapp.activity.LoginActivity;
import com.kkd.kkdapp.activity.RegisterActivity;
import com.kkd.kkdapp.activity.SelectedBidActivity;
import com.kkd.kkdapp.activity.SignRuleActivity;
import com.kkd.kkdapp.adapter.CycleViewPagerAdapter;
import com.kkd.kkdapp.adapter.IconImagePagerAdapter;
import com.kkd.kkdapp.adapter.PrivilegeViewPagerAdapter;
import com.kkd.kkdapp.adapter.PrivilegeViewPagerAdapter.OnViewPagerItemListener;
import com.kkd.kkdapp.adapter.RegularSelectorAdapter;
import com.kkd.kkdapp.http.entity.AllAccountInfo;
import com.kkd.kkdapp.http.entity.AllConfig;
import com.kkd.kkdapp.http.entity.HomeRecommend;
import com.kkd.kkdapp.http.entity.MyProperty;
import com.kkd.kkdapp.http.entity.Privilege;
import com.kkd.kkdapp.listener.OnSingleClickListener;
import com.kkd.kkdapp.view.CycleViewPager;
import com.kkd.kkdapp.view.KKdDialog;
import com.kkd.kkdapp.view.MyRelativeLayout;
import com.kkd.kkdapp.view.MyRelativeLayout.OnItemClick;
import com.kkd.kkdapp.view.ShareView;
import com.kkd.kkdapp.view.ShareView.ShareCallback;
import com.kkd.kkdapp.view.EditText.FinanceEditText;
import com.kkd.kkdapp.view.EditText.FinanceEditText.onFinanceEditListener;
import com.kkd.kkdapp.view.banner.CycleBannerView;
import com.kkd.kkdapp.view.banner.Transformer;
import com.kkd.kkdapp.view.banner.loader.LBannerImgLoader;
import com.kkd.kkdapp.view.rainView.RainView;
import com.kkd.kkdapp.view.rainView.RainView.StopAnimation;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;

@SuppressLint("InflateParams")
public class DialogUtils {

	public static Dialog generateDialog(Context ctx, String rid,
			OnClickListener confirmListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.alert_dialog, null);
		TextView tvContent = (TextView) view.findViewById(R.id.dialog_message);
		tvContent.setText(rid);
		TextView confirmBtn = (TextView) view.findViewById(R.id.confirm);
		confirmBtn.setOnClickListener(confirmListener);
		Dialog mAlertDialog = new Dialog(ctx, R.style.Dialog);
		mAlertDialog.setContentView(view);
		mAlertDialog.setCanceledOnTouchOutside(false);
		return mAlertDialog;
	}

	public static Dialog generate2BDialog(Context ctx, String text,
			String button1, String button2, OnClickListener confirmListener,
			OnClickListener cancleListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.alert_dialog_2button, null);
		TextView tvContent = (TextView) view.findViewById(R.id.dialog_message);
		tvContent.setText(text);
		TextView confirmBtn = (TextView) view.findViewById(R.id.confirm);
		confirmBtn.setText(button1);
		TextView cancleBtn = (TextView) view.findViewById(R.id.cancle);
		cancleBtn.setText(button2);
		confirmBtn.setOnClickListener(confirmListener);
		cancleBtn.setOnClickListener(cancleListener);
		Dialog mAlertDialog = new Dialog(ctx, R.style.Dialog);
		mAlertDialog.setContentView(view);
		mAlertDialog.setCanceledOnTouchOutside(false);
		return mAlertDialog;
	}

	/**************************************************************
	 * 
	 * 投标抽奖活动 ，dialog
	 * 
	 **************************************************************/
	public static Dialog getTenderAffirmDialog(Context context, String text,
			int highlightStart, int highlightlength,
			OnClickListener confirmListener) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.take_out_award, null);
		RelativeLayout close = (RelativeLayout) view.findViewById(R.id.close);
		close.setOnClickListener(confirmListener);
		TextView take_out_tv = (TextView) view.findViewById(R.id.take_out_tv);
		Button take_out_bgf = (Button) view.findViewById(R.id.take_out_bgf);
		Typeface tf = Typeface
				.createFromAsset(context.getAssets(), "w5gb5.ttc");
		SpannableString msp = new SpannableString(text);

		// // 设置字体
		// msp.setSpan(tf, highlightStart, highlightStart + highlightlength,
		// Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
		// // 设置字体
		// msp.setSpan(tf, 0, highlightStart, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
		// // 设置字体
		// msp.setSpan(tf, highlightStart + highlightlength, text.length() - 1,
		// Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
		// // 设置字体大小
		msp.setSpan(new AbsoluteSizeSpan(SystemUtils.dip2px(context, 34)),
				highlightStart, highlightStart + highlightlength,
				Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
		// 设置字体颜色
		msp.setSpan(new ForegroundColorSpan(0xffff6009), highlightStart,
				highlightStart + highlightlength,
				Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

		take_out_tv.setText(msp);
		take_out_tv.setTypeface(tf);
		take_out_bgf.setTypeface(tf);
		take_out_bgf.setOnClickListener(confirmListener);
		Dialog mDialog = new Dialog(context, R.style.dialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		return mDialog;

	}

	/**************************************************************
	 * 
	 * 投标抽奖活动 ，dialog
	 * 
	 **************************************************************/
	public static Dialog getTenderAffirmDialog(Context context,
			OnClickListener confirmListener) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.take_success_award, null);
		Button luck_draw = (Button) view.findViewById(R.id.luck_draw);
		RelativeLayout close_rl = (RelativeLayout) view
				.findViewById(R.id.close_rl);
		luck_draw.setOnClickListener(confirmListener);
		close_rl.setOnClickListener(confirmListener);
		Dialog mDialog = new Dialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		return mDialog;

	}

	/**************************************
	 * 首页公告
	 **************************************/
	@SuppressLint("NewApi")
	public static Dialog getHomeNoticeDialog(Context context, String title,
			String desc, OnClickListener confirmListener) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.homenoticedialog, null);
		final TextView desc_tv = (TextView) view.findViewById(R.id.desc_tv);
		RelativeLayout close = (RelativeLayout) view.findViewById(R.id.close);
		close.setOnClickListener(confirmListener);
		desc_tv.setText(desc);
		TextView title_tv = (TextView) view.findViewById(R.id.title_tv);
		title_tv.setText(title);
		TextPaint paint = title_tv.getPaint();
		paint.setFakeBoldText(true);
		Dialog mDialog = new Dialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		return mDialog;
	}

	/**************************************
	 * 账户中心操作提示
	 **************************************/
	public static KKdDialog mPopDialog;

	public static void reLayoutPopDialog(Context context, boolean is) {

		int dp25 = SystemUtils.dip2px(context, 25);
		int dp50 = SystemUtils.dip2px(context, 50);
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
			ImageView img1 = (ImageView) mPopDialog
					.findViewById(R.id.step1_img1);

			String json = PreferenceUtils.getInstance().getMyproperty(context);
			MyProperty myProperty = null;
			if (!TextUtils.isEmpty(json)) {

				Gson gson = new Gson();
				AllAccountInfo mAllAccountInfo = gson.fromJson(json,
						AllAccountInfo.class);
				myProperty = mAllAccountInfo.getOtherData();

			}
			if (myProperty != null
					&& !TextUtils.isEmpty(myProperty.getSafetyTips())) {

			}
			LayoutParams params1 = img1.getLayoutParams();
			params1.height = SystemUtils.dip2px(context, is ? 332 : 302);
			img1.setLayoutParams(params1);

			ImageView img2 = (ImageView) mPopDialog
					.findViewById(R.id.ImageView021);
			LayoutParams params2 = img2.getLayoutParams();
			params2.height = SystemUtils.dip2px(context, is ? 459 : 429);
			img2.setLayoutParams(params2);

			TextView ignore_bt = (TextView) mPopDialog
					.findViewById(R.id.ignore_bt);
			ignore_bt.setPadding(dp25, dp50, dp25, dp25);
		} else {
			ImageView img1 = (ImageView) mPopDialog
					.findViewById(R.id.step1_img1);
			LayoutParams params1 = img1.getLayoutParams();
			params1.height = SystemUtils.dip2px(context, is ? 334 : 304)
					- SystemUtils.getStatusBarHeight(context);
			img1.setLayoutParams(params1);

			ImageView img2 = (ImageView) mPopDialog
					.findViewById(R.id.ImageView021);
			LayoutParams params2 = img2.getLayoutParams();
			params2.height = SystemUtils.dip2px(context, is ? 459 : 429)
					- SystemUtils.getStatusBarHeight(context);
			img2.setLayoutParams(params2);

			TextView ignore_bt = (TextView) mPopDialog
					.findViewById(R.id.ignore_bt);
			ignore_bt.setPadding(dp25, dp25, dp25, dp25);
		}
	}

	public static Dialog generatePopDialog(Context context) {
		boolean is = false;
		String json = PreferenceUtils.getInstance().getMyproperty(context);
		if (json == null || "".equals(json)) {
			is = false;
		} else {

			Gson gson = new Gson();
			AllAccountInfo mAllAccountInfo = gson.fromJson(json,
					AllAccountInfo.class);
			is = !TextUtils.isEmpty(mAllAccountInfo.getOtherData()
					.getSafetyTips());

		}
		View view = LayoutInflater.from(context).inflate(
				R.layout.know_popupwindow, null);
		if (mPopDialog != null) {
			mPopDialog.cancel();
			mPopDialog = null;
		}
		mPopDialog = new KKdDialog(context, R.style.TransparentDialog);
		mPopDialog.setContentView(view);

		final LinearLayout step1_line = (LinearLayout) view
				.findViewById(R.id.step1_line);
		final LinearLayout step2_line = (LinearLayout) view
				.findViewById(R.id.step2_line);
		step1_line.setVisibility(View.VISIBLE);
		step2_line.setVisibility(View.GONE);
		final TextView ignore_bt = (TextView) view.findViewById(R.id.ignore_bt);
		ignore_bt.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				mPopDialog.dismiss();
			}
		});
		view.setTag("1");
		view.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (v.getTag().toString().equals("1")) {
					step1_line.setVisibility(View.GONE);
					step2_line.setVisibility(View.VISIBLE);
					ignore_bt.setVisibility(View.GONE);
					v.setTag("2");
				} else {
					mPopDialog.dismiss();
				}

			}
		});
		reLayoutPopDialog(context, is);
		return mPopDialog;
	}

	/**************************************
	 * 首页操作提示
	 **************************************/
	public static Dialog getMyDialog(Context ctx) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.home_popupwindow, null);
		final Dialog mDialog = new Dialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);

		// final ImageView close = (ImageView) view.findViewById(R.id.close);
		// final RelativeLayout head_rl = (RelativeLayout) view
		// .findViewById(R.id.head_rl);
		// final ImageView msg_tip = (ImageView)
		// view.findViewById(R.id.msg_tip);
		// close.setVisibility(View.GONE);
		// msg_tip.setVisibility(View.GONE);
		// view.setTag("1");
		view.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// if (v.getTag().toString().equals("1")) {
				// head_rl.setVisibility(View.GONE);
				// msg_tip.setVisibility(View.VISIBLE);
				// close.setVisibility(View.VISIBLE);
				// v.setTag("2");
				// } else {
				mDialog.dismiss();
				// }

			}
		});

		return mDialog;
	}

	/**************************************
	 * 认购成功后对话框
	 **************************************/
	public static Dialog subscribeDialog(Context ctx, int rid,
			OnClickListener confirmListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.alert_dialog_subscribe, null);
		Dialog mAlertDialog = new Dialog(ctx, R.style.Dialog);
		TextView tvContent = (TextView) view
				.findViewById(R.id.dialog_message_subscribe);
		tvContent.setText(rid);
		mAlertDialog.setContentView(view);
		TextView confirmBtn = (TextView) view
				.findViewById(R.id.confirm_subscribe);
		confirmBtn.setOnClickListener(confirmListener);
		TextView cancelBtn = (TextView) view
				.findViewById(R.id.cancel_subscribe);
		cancelBtn.setVisibility(View.GONE);
		cancelBtn.setOnClickListener(confirmListener);
		mAlertDialog.setCanceledOnTouchOutside(false);
		return mAlertDialog;
	}

	public static Dialog subscribeDialog(Context ctx, String rid,
			OnClickListener confirmListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.alert_dialog_subscribe, null);
		Dialog mAlertDialog = new Dialog(ctx, R.style.Dialog);
		TextView tvContent = (TextView) view
				.findViewById(R.id.dialog_message_subscribe);
		tvContent.setText(rid);
		mAlertDialog.setContentView(view);
		TextView confirmBtn = (TextView) view
				.findViewById(R.id.confirm_subscribe);
		confirmBtn.setOnClickListener(confirmListener);
		TextView cancelBtn = (TextView) view
				.findViewById(R.id.cancel_subscribe);
		cancelBtn.setVisibility(View.GONE);
		confirmBtn.setOnClickListener(confirmListener);
		cancelBtn.setOnClickListener(confirmListener);
		mAlertDialog.setCanceledOnTouchOutside(false);
		return mAlertDialog;
	}

	/**************************************
	 * 添加银行卡对话框
	 **************************************/
	public static Dialog addBankDialog(Context ctx, String rid,
			OnClickListener confirmListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.alert_dialog_addbank, null);
		Dialog mAlertDialog = new Dialog(ctx, R.style.Dialog);
		TextView tvContent = (TextView) view
				.findViewById(R.id.dialog_message_addbank);
		tvContent.setText(rid);
		mAlertDialog.setContentView(view);
		TextView confirmBtn = (TextView) view
				.findViewById(R.id.confirm_addbank);
		confirmBtn.setOnClickListener(confirmListener);
		mAlertDialog.setCanceledOnTouchOutside(false);
		return mAlertDialog;
	}

	/**************************************
	 * 解绑银行卡对话框
	 **************************************/
	public static Dialog deleteBankDialog(Context ctx, String rid,
			OnClickListener confirmListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.alert_dialog_deletebank, null);
		Dialog mAlertDialog = new Dialog(ctx, R.style.Dialog);
		TextView tvContent = (TextView) view
				.findViewById(R.id.dialog_message_deletebank);
		tvContent.setText(rid);
		mAlertDialog.setContentView(view);
		TextView confirmBtn = (TextView) view
				.findViewById(R.id.cancel_deletebank);
		confirmBtn.setOnClickListener(confirmListener);
		TextView cancelBtn = (TextView) view
				.findViewById(R.id.confirm_deletebank);
		cancelBtn.setOnClickListener(confirmListener);
		if (rid.startsWith("客服电话")) {
			cancelBtn.setText("确定");
		} else if (rid.startsWith("客服邮箱")) {
			cancelBtn.setText("发送");
		} else if (rid.startsWith("有最新的软件")) {
			cancelBtn.setText("下载");
			confirmBtn.setText("以后再说");
		}
		mAlertDialog.setCanceledOnTouchOutside(false);
		return mAlertDialog;
	}

	/**************************************
	 * 版本更新文件已下载弹窗
	 **************************************/
	public static Dialog haveDownloadedDialog(Context ctx, String rid,
			OnClickListener confirmListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.alert_dialog_downloaded, null);
		Dialog mAlertDialog = new Dialog(ctx, R.style.Dialog);
		TextView tvContent = (TextView) view
				.findViewById(R.id.dialog_message_deletebank);
		tvContent.setText(rid);
		mAlertDialog.setContentView(view);
		TextView confirmBtn = (TextView) view
				.findViewById(R.id.cancel_deletebank);
		confirmBtn.setOnClickListener(confirmListener);
		TextView cancelBtn = (TextView) view
				.findViewById(R.id.confirm_deletebank);
		cancelBtn.setOnClickListener(confirmListener);
		TextView redownload = (TextView) view.findViewById(R.id.redownload);
		redownload.setOnClickListener(confirmListener);
		mAlertDialog.setCanceledOnTouchOutside(false);
		mAlertDialog.setCancelable(false);
		return mAlertDialog;
	}

	/********************************
	 * 加载对话框
	 ********************************/
	public static Dialog toLoadDialog(Context context, String content) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.toloaddialog, null);
		TextView details = (TextView) view.findViewById(R.id.details);
		ImageView progressbar = (ImageView) view.findViewById(R.id.progressbar);
		GifDrawable drawable;
		try {
			drawable = new GifDrawable(context.getResources(),
					R.drawable.loading_gif);

			progressbar.setImageDrawable(drawable);
		} catch (NotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		details.setText(content);
		Dialog mDialog = new KKdDialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		try {
			mDialog.show();
		} catch (Exception e) {
			// TODO: handle exception
		}

		return mDialog;
	}

	/********************************
	 * 如何还款？
	 ********************************/
	public static Dialog howRepayment(Context context,
			OnClickListener mOnClickListener) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.howrepaymentdialog, null);
		TextView close_tv = (TextView) view.findViewById(R.id.close_tv);
		close_tv.setOnClickListener(mOnClickListener);
		Dialog mDialog = new Dialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.show();
		return mDialog;
	}

	/********************************
	 * 余额不足对话框
	 ********************************/
	public static Dialog notSufficientFundsDialog(Context context,
			OnClickListener mOnClickListener, boolean isBid) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.notsufficientfundsdialog, null);
		TextView cancel = (TextView) view.findViewById(R.id.cancel_tv);
		TextView tv_content = (TextView) view.findViewById(R.id.tv_content);
		TextView recharge = (TextView) view.findViewById(R.id.recharge_tv);
		String type = isBid ? "账户余额不足请先充值；如需要大额充值，请登录快快贷网站进行操作"
				: "账户余额不足请先充值；如需要大额充值，请登录快快贷网站进行操作";
		tv_content.setText(type);
		cancel.setOnClickListener(mOnClickListener);
		recharge.setOnClickListener(mOnClickListener);
		Dialog mDialog = new KKdDialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		return mDialog;
	}

	/********************************
	 * 签到成功对话框
	 ********************************/
	public static Dialog signInSuccessDialog(Context ctx, String couponflag,
			String summaryTop, String summaryFooter, int addHappyCurrency,
			String couponDesc, String couponAmount,
			OnClickListener confirmListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.signsuccessdialog, null);
		// 未满签获取的快乐币数量
		TextView tv_num_add = (TextView) view.findViewById(R.id.tv_num_add);
		// 满签时获得的快乐币数量
		TextView tv_num_add_full = (TextView) view
				.findViewById(R.id.tv_num_add_full);
		// 满签额外赠送的优惠券面额
		TextView tv_num_add_extra_full = (TextView) view
				.findViewById(R.id.tv_num_add_extra_full);
		// 再连续签到。。。天。。。
		TextView tv_time_signIntip = (TextView) view
				.findViewById(R.id.tv_time_signIntip);
		// 我知道了
		TextView tv_iknow = (TextView) view.findViewById(R.id.tv_iknow);
		// 了解签到规则
		TextView tv_rule = (TextView) view.findViewById(R.id.tv_rule);
		// 已连续签到多少天
		TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
		// 满签优惠券类型
		TextView tv_type_add_extra_full = (TextView) view
				.findViewById(R.id.tv_type_add_extra_full);
		// 满签rmb标识
		TextView tv_flag_type_add_extra_full = (TextView) view
				.findViewById(R.id.tv_flag_type_add_extra_full);
		// 未满签布局
		RelativeLayout rel_nofull = (RelativeLayout) view
				.findViewById(R.id.rel_nofull);
		// 满签布局
		RelativeLayout rel_full = (RelativeLayout) view
				.findViewById(R.id.rel_full);

		tv_title.setText(summaryTop);
		tv_time_signIntip.setText(summaryFooter);
		tv_num_add.setText(addHappyCurrency + "");
		tv_num_add_full.setText(addHappyCurrency + "");
		tv_type_add_extra_full.setText(couponDesc);
		tv_num_add_extra_full.setText(couponAmount);
		tv_flag_type_add_extra_full.setText("￥");
		if ("0".equals(couponflag)) {
			rel_nofull.setVisibility(View.VISIBLE);
			rel_full.setVisibility(View.GONE);
		} else if ("1".equals(couponflag)) {
			rel_nofull.setVisibility(View.GONE);
			rel_full.setVisibility(View.VISIBLE);
			if ("加息券".equals(couponDesc)) {
				tv_flag_type_add_extra_full.setText("+");
			} else {
				tv_flag_type_add_extra_full.setText("￥");
			}
		}

		Dialog mDialog = new Dialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);

		tv_iknow.setOnClickListener(confirmListener);
		tv_rule.setOnClickListener(confirmListener);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.show();
		return mDialog;
	}

	/********************************
	 * 投标等待
	 ********************************/
	public static Dialog tendertoLoadDialog(Context context, String content,
			String loading) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.tendertoloaddialog, null);
		TextView details = (TextView) view.findViewById(R.id.details);
		TextView tv_loading = (TextView) view.findViewById(R.id.tv_loading);
		tv_loading.setText(loading);
		ImageView progressbar = (ImageView) view.findViewById(R.id.progressbar);
		GifDrawable drawable;
		try {
			drawable = new GifDrawable(context.getResources(),
					R.drawable.loading_gif);

			progressbar.setImageDrawable(drawable);
		} catch (NotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		details.setText(content);
		Dialog mDialog = new KKdDialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		return mDialog;
	}

	/********************************
	 * 投标成功结果Dialog
	 ********************************/
	public static Dialog tenderSucceedResult(Context context, String title,
			boolean examineFlag, String continue_bt_tx, String bidName,
			String tenderAmout, int bidDeadline, String bidDeadline_company,
			String expected_return, String repayment, String startInterest,
			int bidPeriodAdd, OnClickListener mOnClickListener, String button_tv) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.tendersucceedresult, null);
		RelativeLayout draw_lottery_rl = (RelativeLayout) view
				.findViewById(R.id.draw_lottery_rl);
		draw_lottery_rl.setOnClickListener(mOnClickListener);
		TextView hint_tv = (TextView) view.findViewById(R.id.hint_tv);
		hint_tv.setText(title);
		TextView title_tv = (TextView) view.findViewById(R.id.title_tv);
		title_tv.setText(title);
		Button continue_bt = (Button) view.findViewById(R.id.continue_bt);
		continue_bt.setPadding(0, 0, 0, 0);
		continue_bt.setText(continue_bt_tx);
		continue_bt.setOnClickListener(mOnClickListener);
		TextView examine = (TextView) view.findViewById(R.id.examine);
		if (examineFlag) {
			examine.setVisibility(View.VISIBLE);
		} else {
			examine.setVisibility(View.GONE);
		}
		examine.setText(button_tv);
		examine.setOnClickListener(mOnClickListener); // 查看投标记录
		RelativeLayout result_title_img = (RelativeLayout) view
				.findViewById(R.id.result_title_img);
		result_title_img.setOnClickListener(mOnClickListener);
		TextView bidname = (TextView) view.findViewById(R.id.bidname);
		bidname.setText(bidName); // 标的名字
		TextView tenderamount = (TextView) view.findViewById(R.id.tenderamount);
		tenderamount.setText(tenderAmout + ""); // 投标金额
		TextView biddeadline = (TextView) view.findViewById(R.id.biddeadline);
		TextView biddeadline_company1 = (TextView) view
				.findViewById(R.id.biddeadline_company1);
		TextView biddeadline1 = (TextView) view.findViewById(R.id.biddeadline1);
		if (bidPeriodAdd == 0) {
			biddeadline.setText(bidDeadline + ""); // 投资期限
			biddeadline_company1.setVisibility(View.GONE);
			biddeadline1.setVisibility(View.GONE);
		} else {
			biddeadline_company1.setVisibility(View.VISIBLE);
			biddeadline1.setVisibility(View.VISIBLE);
			biddeadline.setText(bidDeadline + ""); // 投资期限
			biddeadline_company1.setText(bidDeadline_company + "+");
			biddeadline1.setText("" + bidPeriodAdd);
		}
		TextView biddeadline_company = (TextView) view
				.findViewById(R.id.biddeadline_company);
		biddeadline_company.setText(bidDeadline_company); // 投资期限单位
		TextView expected_return_tv = (TextView) view
				.findViewById(R.id.expected_return_tv);
		expected_return_tv.setText(expected_return); // 预计收益
		TextView repayment_tv = (TextView) view.findViewById(R.id.repayment_tv);
		repayment_tv.setText(repayment); // 还款方式
		TextView startInterest_tv = (TextView) view
				.findViewById(R.id.startInterest_tv);
		startInterest_tv.setText(startInterest); // 开始计息
		Dialog mDialog = new Dialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		return mDialog;
	}

	/********************************
	 * 投标成功结果Dialog
	 ********************************/
	public static Dialog tenderSucceedResult(Context context, String bidName,
			String tenderAmout, int bidDeadline, String bidDeadline_company,
			String expected_return, String repayment, String startInterest,
			OnClickListener mOnClickListener) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.tendersucceedresult1, null);
		Button examine = (Button) view.findViewById(R.id.examine);
		examine.setOnClickListener(mOnClickListener); // 查看投标记录
		RelativeLayout result_title_img = (RelativeLayout) view
				.findViewById(R.id.result_title_img);
		result_title_img.setOnClickListener(mOnClickListener);
		TextView bidname = (TextView) view.findViewById(R.id.bidname);
		bidname.setText(bidName); // 标的名字
		TextView tenderamount = (TextView) view.findViewById(R.id.tenderamount);
		tenderamount.setText(tenderAmout + ""); // 投标金额
		TextView biddeadline = (TextView) view.findViewById(R.id.biddeadline);
		biddeadline.setText(bidDeadline + ""); // 投资期限
		TextView biddeadline_company = (TextView) view
				.findViewById(R.id.biddeadline_company);
		biddeadline_company.setText(bidDeadline_company); // 投资期限单位
		TextView expected_return_tv = (TextView) view
				.findViewById(R.id.expected_return_tv);
		expected_return_tv.setText(expected_return); // 预计收益
		TextView repayment_tv = (TextView) view.findViewById(R.id.repayment_tv);
		repayment_tv.setText(repayment); // 还款方式
		TextView startInterest_tv = (TextView) view
				.findViewById(R.id.startInterest_tv);
		startInterest_tv.setText(startInterest); // 开始计息
		Dialog mDialog = new Dialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		return mDialog;
	}

	static Dialog mDialog;
	public static View view;
	public static Timer mTimer;
	private static Handler mHandler = new Handler();
	public static TextView tv_content;
	public static RelativeLayout rel_toast;

	/********************************
	 * 投标失败结果Dialog
	 ********************************/
	public static void tenderBeDefeatedResult(Context context,
			String bedefeatedResult) {
		if (view != null) {
			view = null;
		}
		if (tv_content != null) {
			tv_content = null;
		}
		if (rel_toast != null) {
			rel_toast = null;
		}

		if (mDialog != null) {
			mDialog.cancel();
			mDialog = null;
		}
		if (mTimer != null) {
			mTimer.cancel();
			mTimer = null;
		}
		view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.tenderbedefeatedresult, null);
		tv_content = (TextView) view.findViewById(R.id.bedefeated);
		tv_content.setText(bedefeatedResult);
		rel_toast = (RelativeLayout) view.findViewById(R.id.rel_toast);
		rel_toast.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
					mDialog = null;
				}
				if (mTimer != null) {
					mTimer.cancel();
					mTimer = null;
				}
			}
		});
		mDialog = new Dialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.setCancelable(false);
		mDialog.show();
		AlphaAnimation alphaIn = new AlphaAnimation(0, 1);
		alphaIn.setDuration(500);
		view.startAnimation(alphaIn);
		mTimer = new Timer();
		mTimer.schedule(new TimerTask() {

			@Override
			public void run() {
				mHandler.post(new Runnable() {

					@Override
					public void run() {
						AlphaAnimation alphaOut = new AlphaAnimation(1, 0);
						alphaOut.setDuration(500);
						view.startAnimation(alphaOut);
						alphaOut.setAnimationListener(new AnimationListener() {

							@Override
							public void onAnimationStart(Animation animation) {

							}

							@Override
							public void onAnimationRepeat(Animation animation) {

							}

							@Override
							public void onAnimationEnd(Animation animation) {

								if (mDialog != null) {
									mDialog.cancel();
									mDialog = null;
								}
								if (mTimer != null) {
									mTimer.cancel();
									mTimer = null;
								}
							}
						});
					}
				});
			}
		}, 1500);
	}

	public static Dialog tenderBeDefeatedResult(Context context,
			String bedefeatedResult, OnClickListener mOnClickListener) {

		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.tenderbedefeatedresult1, null);
		TextView tv_content = (TextView) view.findViewById(R.id.bedefeated);
		tv_content.setText(bedefeatedResult);
		Button rel_toast = (Button) view.findViewById(R.id.rel_toast);
		rel_toast.setOnClickListener(mOnClickListener);
		Dialog mDialog = new KKdDialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.setCancelable(false);
		mDialog.show();
		return mDialog;
	}

	/********************************
	 * 注册结果提示dialog
	 ********************************/
	public static Dialog registerResDialog(Context context, String desc,
			String couponAmount, OnClickListener mOnConfirmListener) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.register_res_dialog, null);
		TextView coupon_count = (TextView) view.findViewById(R.id.coupon_count);
		coupon_count.setText(couponAmount);
		TextView tip = (TextView) view.findViewById(R.id.tip);
		tip.setText(desc);
		TextView confirm = (TextView) view.findViewById(R.id.confirm);
		confirm.setOnClickListener(mOnConfirmListener);
		Dialog mDialog = new Dialog(context, R.style.Dialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		return mDialog;
	}

	/********************************
	 * 语音验证码dialog
	 ********************************/
	public static Dialog YuyinCodeDialog(Context context, String phone,
			OnClickListener mOnConfirmListener,
			OnClickListener mOnConfirmListener2, OnClickListener cancleListener) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.yuyin_code_dialog, null);
		TextView phone_tv = (TextView) view.findViewById(R.id.phone);
		phone_tv.setText(phone);
		TextView cancle_bt = (TextView) view.findViewById(R.id.cancle_bt);
		cancle_bt.setOnClickListener(cancleListener);

		Button yuyin_bt = (Button) view.findViewById(R.id.yuyin_bt);
		yuyin_bt.setOnClickListener(mOnConfirmListener);

		Button resend_bt = (Button) view.findViewById(R.id.resend_bt);
		resend_bt.setOnClickListener(mOnConfirmListener2);

		Dialog mDialog = new Dialog(context, R.style.dialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		return mDialog;
	}

	/********************************
	 * 认购结果dialog
	 ********************************/
	public static Dialog subscriptionResultsDialog(Context context, int imgID,
			String promp, String product, String amount, String bt_tv,
			boolean viewflag, OnClickListener mOnClickListener) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.subscriptionresultsdialog, null);
		ImageView subscription_icon = (ImageView) view
				.findViewById(R.id.subscription_icon);
		subscription_icon.setImageResource(imgID);
		TextView promp_tv = (TextView) view.findViewById(R.id.promp_tv);
		promp_tv.setText(promp);
		TextView product_tv = (TextView) view.findViewById(R.id.product_tv);
		product_tv.setText(product);
		TextView amount_tv = (TextView) view.findViewById(R.id.amount_tv);
		amount_tv.setText(amount + "元");
		Button return_bt = (Button) view.findViewById(R.id.return_bt);
		return_bt.setText(bt_tv);
		return_bt.setOnClickListener(mOnClickListener);
		RelativeLayout result_title_img = (RelativeLayout) view
				.findViewById(R.id.result_title_img);
		result_title_img.setOnClickListener(mOnClickListener);
		RelativeLayout product_rl = (RelativeLayout) view
				.findViewById(R.id.product_rl);
		RelativeLayout amount_rl = (RelativeLayout) view
				.findViewById(R.id.amount_rl);
		View line1 = view.findViewById(R.id.line1);
		View line2 = view.findViewById(R.id.line2);
		if (viewflag) {
			product_rl.setVisibility(View.GONE);
			amount_rl.setVisibility(View.GONE);
			line1.setVisibility(View.GONE);
			line2.setVisibility(View.GONE);
		} else {
			product_rl.setVisibility(View.VISIBLE);
			amount_rl.setVisibility(View.VISIBLE);
			line1.setVisibility(View.VISIBLE);
			line2.setVisibility(View.VISIBLE);
		}
		Dialog mDialog = new Dialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		return mDialog;
	}

	/********************************
	 * 收益计算器dialog
	 ********************************/
	public static void showCalculateWindow(final Context context, View parent,
			String bidPeriodType, long bidFreeAmount, final long bidAmount,
			final long totalLixi, int bidPeriod, int bidPeriodAdd) {
		View layout = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.calculatepupopwindow, null);
		TextView deadline_tv = (TextView) layout.findViewById(R.id.deadline_tv);
		if (!TextUtils.isEmpty(bidPeriodType)) {
			if ("天".equals(bidPeriodType)) {
				deadline_tv.setText("投资期限(" + bidPeriodType + ")");
			} else if ("月".equals(bidPeriodType)) {
				deadline_tv.setText("投资期限(个" + bidPeriodType + ")");
			}
		}
		TextView deadline = (TextView) layout.findViewById(R.id.deadline);
		final TextView earning = (TextView) layout.findViewById(R.id.earning);
		if (bidPeriodAdd == 0) {
			deadline.setText("" + bidPeriod);
		} else {
			deadline.setText("" + bidPeriod + "+" + bidPeriodAdd);
		}

		final PopupWindow mPopupWindow = new PopupWindow(layout,
				WindowManager.LayoutParams.FILL_PARENT,
				WindowManager.LayoutParams.FILL_PARENT, true);
		mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
		mPopupWindow.setOutsideTouchable(true);
		mPopupWindow
				.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
		final WindowManager.LayoutParams params = ((Activity) context)
				.getWindow().getAttributes();
		params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
		((Activity) context).getWindow().setAttributes(params);
		mPopupWindow.showAtLocation(parent, Gravity.CENTER, 0, 0);
		LinearLayout popupwidow_ll = (LinearLayout) layout
				.findViewById(R.id.popupwidow_ll);
		if (mPopupWindow.isShowing()) {
			Animation animation = AnimationUtils.loadAnimation(context,
					R.anim.openparticulars_translate);
			popupwidow_ll.setAnimation(animation);
		} else {

			Animation animation = AnimationUtils.loadAnimation(context,
					R.anim.openparticulars_translate);
			popupwidow_ll.setAnimation(animation);
		}

		FinanceEditText calculate_ed = (FinanceEditText) layout
				.findViewById(R.id.calculate_ed);
		calculate_ed.setDecimalDigits(0);
		calculate_ed.setLimitMax(bidAmount / 100);
		calculate_ed.setFinanceEditListener(new onFinanceEditListener() {

			@Override
			public void onValueChanged(double toValue, double fromValue) {

			}

			@Override
			public void onOutLimit() {
				// TODO Auto-generated method stub

			}

			@Override
			public void afterValueChanged(double toValue) {
				if (toValue > 0) {
					double estimate = toValue / (bidAmount * 0.01)
							* (totalLixi * 0.01);

					DecimalFormat df = new DecimalFormat("0.00");
					earning.setText(df
							.format(((int) (estimate * 1000) / 10) * 0.01));
				} else {
					earning.setText("0.00");
				}

			}
		});

		RelativeLayout calculate_close = (RelativeLayout) layout
				.findViewById(R.id.calculate_close);
		calculate_close.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				mPopupWindow.dismiss();
			}
		});
		RelativeLayout close = (RelativeLayout) layout.findViewById(R.id.close);
		close.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				mPopupWindow.dismiss();
			}
		});
		mPopupWindow.setOnDismissListener(new OnDismissListener() {

			@Override
			public void onDismiss() {
				params.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
				((Activity) context).getWindow().setAttributes(params);
			}
		});

	}

	/********************************
	 * 债权计算器dialog private long perPrincipal; private long leftTerm; private
	 * long preYearRate; private long activityRate; private long perPrice;
	 ********************************/
	public static void showCalculateWindow(final long perPrincipal,
			final long leftTerm, final long preYearRate,
			final long activityRate, final long perPrice, long perAmount,
			int leftCount, final Context context, View parent) {
		View layout = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.debtcalculatepupopwindow, null);
		final TextView earning = (TextView) layout.findViewById(R.id.earning);
		TextView deadline = (TextView) layout.findViewById(R.id.deadline);
		final DecimalFormat df = new DecimalFormat("0.01");
		deadline.setText(df.format(perAmount * 0.01));
		final PopupWindow mPopupWindow = new PopupWindow(layout,
				WindowManager.LayoutParams.FILL_PARENT,
				WindowManager.LayoutParams.FILL_PARENT, true);
		mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
		mPopupWindow.setOutsideTouchable(true);
		mPopupWindow
				.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
		final WindowManager.LayoutParams params = ((Activity) context)
				.getWindow().getAttributes();
		params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
		((Activity) context).getWindow().setAttributes(params);
		mPopupWindow.showAtLocation(parent, Gravity.CENTER, 0, 0);
		LinearLayout popupwidow_ll = (LinearLayout) layout
				.findViewById(R.id.popupwidow_ll);
		if (mPopupWindow.isShowing()) {
			Animation animation = AnimationUtils.loadAnimation(context,
					R.anim.openparticulars_translate);
			popupwidow_ll.setAnimation(animation);
		} else {

			Animation animation = AnimationUtils.loadAnimation(context,
					R.anim.openparticulars_translate);
			popupwidow_ll.setAnimation(animation);
		}

		final FinanceEditText calculate_ed = (FinanceEditText) layout
				.findViewById(R.id.calculate_ed);
		calculate_ed.setHint("当前最多购买" + leftCount + "份");
		calculate_ed.setDecimalDigits(0);
		calculate_ed.setLimitMax(leftCount);
		calculate_ed.setFinanceEditListener(new onFinanceEditListener() {

			@Override
			public void onValueChanged(double toValue, double fromValue) {

			}

			@Override
			public void onOutLimit() {
				// TODO Auto-generated method stub

			}

			@Override
			public void afterValueChanged(double toValue) {
				if (toValue > 0) {
					double principal = perPrincipal * toValue;
					double income = principal + principal * leftTerm / 12.0
							* (preYearRate / 10000.0) + principal * leftTerm
							/ 12.0 * (activityRate / 10000.0);
					double shouyi = income - perPrice * toValue;
					earning.setText(df.format((long) shouyi * 0.01));
				} else {
					earning.setText("0.00");
				}

			}
		});

		RelativeLayout calculate_close = (RelativeLayout) layout
				.findViewById(R.id.calculate_close);
		calculate_close.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				mPopupWindow.dismiss();
			}
		});
		RelativeLayout close = (RelativeLayout) layout.findViewById(R.id.close);
		close.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				mPopupWindow.dismiss();
			}
		});

		mPopupWindow.setOnDismissListener(new OnDismissListener() {

			@Override
			public void onDismiss() {
				params.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
				((Activity) context).getWindow().setAttributes(params);
			}
		});
	}

	// viewpager对话框

	public static Dialog showViewPagerDialog(Context ctx, int currentItem) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.dialog_viewpager, null);
		ImageView rel_whole = (ImageView) view.findViewById(R.id.close);
		final CycleViewPager viewpager = (CycleViewPager) view
				.findViewById(R.id.viewpager_dialog);

		// 小点组
		LinearLayout group = (LinearLayout) view.findViewById(R.id.ll_dialog);

		// 图片数据源
		int[] imaIdArray = { R.drawable.welcome_icon_1,
				R.drawable.welcome_icon_3, R.drawable.welcome_icon_4 };
		// 小点图片
		final List<ImageView> dots;

		// 滑动点
		dots = new ArrayList<ImageView>();
		for (int i = 0; i < imaIdArray.length; i++) {
			ImageView imageView_dot = new ImageView(ctx);
			imageView_dot.setLayoutParams(new LayoutParams(10, 10));
			dots.add(imageView_dot);
			if (i == 0) {
				dots.get(i).setBackgroundResource(R.drawable.page_focused);
			} else {
				dots.get(i).setBackgroundResource(R.drawable.page_unfocused);
			}

			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
					new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,
							LayoutParams.WRAP_CONTENT));
			layoutParams.leftMargin = 10;
			layoutParams.rightMargin = 10;
			group.addView(imageView_dot, layoutParams);
		}

		final Dialog mDialog = new Dialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		rel_whole.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (mDialog != null) {
					mDialog.dismiss();
					mDialog.cancel();
				}

			}
		});
		CycleViewPagerAdapter cycleViewPagerAdapter = new CycleViewPagerAdapter(
				ctx, imaIdArray, mDialog);
		// 设置Adapter
		viewpager.setDots(dots);
		viewpager.setAdapter(cycleViewPagerAdapter);
		viewpager.setCurrentItem(currentItem);
		return mDialog;
	}

	// viewpager对话框

	public static Dialog showViewPagerDialog(Context ctx, int currentItem,
			String[] imaIdArray, String[] textArray) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.dialog_viewpager, null);
		ImageView close = (ImageView) view.findViewById(R.id.close);
		RelativeLayout rel_whole = (RelativeLayout) view
				.findViewById(R.id.rel_whole);
		final CycleViewPager viewpager = (CycleViewPager) view
				.findViewById(R.id.viewpager_dialog);
		LinearLayout close1 = (LinearLayout) view.findViewById(R.id.close1);

		// 小点组
		LinearLayout group = (LinearLayout) view.findViewById(R.id.ll_dialog);

		// // 图片数据源
		// int[] imaIdArray = { R.drawable.welcome_icon_1,
		// R.drawable.welcome_icon_2, R.drawable.welcome_icon_3,
		// R.drawable.welcome_icon_4 };
		// 小点图片
		final List<ImageView> dots;

		// 滑动点
		dots = new ArrayList<ImageView>();
		for (int i = 0; i < imaIdArray.length; i++) {
			ImageView imageView_dot = new ImageView(ctx);
			imageView_dot.setLayoutParams(new LayoutParams(10, 10));
			dots.add(imageView_dot);
			if (i == 0) {
				dots.get(i).setBackgroundResource(R.drawable.page_focused);
			} else {
				dots.get(i).setBackgroundResource(R.drawable.page_unfocused);
			}

			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
					new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,
							LayoutParams.WRAP_CONTENT));
			layoutParams.leftMargin = 10;
			layoutParams.rightMargin = 10;
			group.addView(imageView_dot, layoutParams);
		}

		final Dialog mDialog = new Dialog(ctx, R.style.TransparentDialog);
		Window window = mDialog.getWindow();
		window.setWindowAnimations(R.style.animationPreview);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		rel_whole.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		close.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		close1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		IconImagePagerAdapter cycleViewPagerAdapter = new IconImagePagerAdapter(
				ctx, imaIdArray, textArray, mDialog);
		// 设置Adapter
		viewpager.setDots(dots);
		viewpager.setPageMargin(SystemUtils.dip2px(ctx, 100));
		viewpager.setAdapter(cycleViewPagerAdapter);
		viewpager.setCurrentItem(currentItem);
		return mDialog;
	}

	// 详情Icon弹窗
	public static Dialog showCharacteristicDialog(Context ctx, int currentItem,
			String[] imaIdArray, final String[] textArray,
			OnItemClick onItemClick) {
		Map<Integer, RelativeLayout> map = new HashMap<Integer, RelativeLayout>();
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.dialog_view, null);
		ImageView close = (ImageView) view.findViewById(R.id.close);
		RelativeLayout close_rl = (RelativeLayout) view
				.findViewById(R.id.close_rl);
		MyRelativeLayout myrl = (MyRelativeLayout) view.findViewById(R.id.mrl);
		for (int i = 0; i < imaIdArray.length; i++) {

			RelativeLayout mRelativeLayout = new RelativeLayout(ctx);

			LayoutParams params_rl = new LayoutParams(
					LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

			mRelativeLayout.setLayoutParams(params_rl);

			ImageView img = new ImageView(ctx);
			LayoutParams params_img = new LayoutParams(SystemUtils.dip2px(ctx,
					244), SystemUtils.dip2px(ctx, 275));
			img.setLayoutParams(params_img);
			final TextView mTextView = new TextView(ctx);
			mTextView.setTextColor(Color.parseColor("#505050"));
			mTextView.setTextSize(12);
			mTextView.setGravity(Gravity.CENTER);
			android.widget.RelativeLayout.LayoutParams params_tv = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(ctx, 204), LayoutParams.WRAP_CONTENT);
			params_tv.leftMargin = SystemUtils.dip2px(ctx, 30);
			params_tv.rightMargin = SystemUtils.dip2px(ctx, 30);
			params_tv.topMargin = SystemUtils.dip2px(ctx, 170);
			mTextView.setLayoutParams(params_tv);
			final String str = textArray[i];
			final Handler mHandler = new Handler() {
				@Override
				public void handleMessage(Message msg) {
					mTextView.setText(str);
				}
			};

			ImageLoader.getInstance().displayImage(imaIdArray[i], img,
					new ImageLoadingListener() {

						@Override
						public void onLoadingStarted(String imageUri, View view) {

						}

						@Override
						public void onLoadingFailed(String imageUri, View view,
								FailReason failReason) {

						}

						@Override
						public void onLoadingComplete(String imageUri,
								View view, Bitmap loadedImage) {
							mHandler.sendEmptyMessage(1);
						}

						@Override
						public void onLoadingCancelled(String imageUri,
								View view) {

						}
					});

			mRelativeLayout.addView(img);
			mRelativeLayout.addView(mTextView);
			map.put(i, mRelativeLayout);
		}
		myrl.setDataSource(map);
		myrl.setTouchListener();
		myrl.setCurrentItem(currentItem);
		myrl.setOnItemClick(onItemClick);
		final KKdDialog mDialog = new KKdDialog(ctx, R.style.TransparentDialog);
		Window window = mDialog.getWindow();
		window.setWindowAnimations(R.style.animationPreview);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		myrl.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		close.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		close_rl.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		return mDialog;
	}

	/********************************
	 * 认购成功结果dialog
	 ********************************/
	public static Dialog subscriptionResultsDialog2(Context context,
			String product, String amount, String rishouyi, String beginJiXi,
			String time2shouyi, OnClickListener mClickListener) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.currenttender_result, null);
		TextView finish_currenttender_result = (TextView) view
				.findViewById(R.id.finish_currenttender_result);
		ImageView imageView_currenttender_result = (ImageView) view
				.findViewById(R.id.imageView_currenttender_result);
		TextView textView_tip_currenttender_result = (TextView) view
				.findViewById(R.id.textView_tip_currenttender_result);
		TextView textView_product_currenttender_result = (TextView) view
				.findViewById(R.id.textView_product_currenttender_result);
		TextView textView_num_tender_currenttender_result = (TextView) view
				.findViewById(R.id.textView_num_tender_currenttender_result);
		TextView textView_rishouyi_tender_currenttender_result = (TextView) view
				.findViewById(R.id.textView_rishouyi_tender_currenttender_result);
		TextView textView_begintime_currenttender_result = (TextView) view
				.findViewById(R.id.textView_begintime_currenttender_result);
		TextView textView_beginseetime_currenttender_result = (TextView) view
				.findViewById(R.id.textView_beginseetime_currenttender_result);
		TextView textView_seeMyCurrent_currenttender_result = (TextView) view
				.findViewById(R.id.textView_seeMyCurrent_currenttender_result);
		TextView examine = (TextView) view.findViewById(R.id.examine);
		// 继续投标
		examine.setOnClickListener(mClickListener);
		// 设置产品名
		textView_product_currenttender_result.setText(product);
		// 设置投资金额
		textView_num_tender_currenttender_result.setText(amount);
		// 设置日收益
		textView_rishouyi_tender_currenttender_result.setText(rishouyi);
		// 设置开始计息
		textView_begintime_currenttender_result.setText(beginJiXi);
		// 设置收益时间
		textView_beginseetime_currenttender_result.setText(time2shouyi);
		// 设置监听
		finish_currenttender_result.setOnClickListener(mClickListener);
		textView_seeMyCurrent_currenttender_result
				.setOnClickListener(mClickListener);
		Dialog mDialog = new Dialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		return mDialog;
	}

	public static Dialog rainDialog(Context context) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.rain_dailog, null);
		RainView rain_dialog = (RainView) view.findViewById(R.id.rain_dialog);

		Dialog mDialog = new Dialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.show();
		return mDialog;
	}

	/********************************
	 * 签到成功对话框
	 ********************************/
	public static Dialog signInSuccessDialog2(Context ctx, String couponflag,
			String summaryTop, String summaryFooter, int addHappyCurrency,
			String couponDesc, String couponAmount,
			OnClickListener confirmListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.signsuccessdialog2, null);
		// 下雨view
		RainView rain_dialog = (RainView) view.findViewById(R.id.rain_dialog);
		// content
		RelativeLayout rel_content = (RelativeLayout) view
				.findViewById(R.id.rel_content);
		// 未满签获取的快乐币数量
		TextView tv_num_add = (TextView) view.findViewById(R.id.tv_num_add);
		// 满签时获得的快乐币数量
		TextView tv_num_add_full = (TextView) view
				.findViewById(R.id.tv_num_add_full);
		// 满签额外赠送的优惠券面额
		TextView tv_num_add_extra_full = (TextView) view
				.findViewById(R.id.tv_num_add_extra_full);
		// 再连续签到。。。天。。。
		TextView tv_time_signIntip = (TextView) view
				.findViewById(R.id.tv_time_signIntip);
		// 我知道了
		TextView tv_iknow = (TextView) view.findViewById(R.id.tv_iknow);
		// 了解签到规则
		TextView tv_rule = (TextView) view.findViewById(R.id.tv_rule);
		// 已连续签到多少天
		TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
		// 满签优惠券类型
		TextView tv_type_add_extra_full = (TextView) view
				.findViewById(R.id.tv_type_add_extra_full);
		// 满签rmb标识
		TextView tv_flag_type_add_extra_full = (TextView) view
				.findViewById(R.id.tv_flag_type_add_extra_full);
		// 未满签布局
		RelativeLayout rel_nofull = (RelativeLayout) view
				.findViewById(R.id.rel_nofull);
		// 满签布局
		RelativeLayout rel_full = (RelativeLayout) view
				.findViewById(R.id.rel_full);
		rain_dialog.setView(rel_content);
		tv_title.setText(summaryTop);
		tv_time_signIntip.setText(summaryFooter);
		tv_num_add.setText(addHappyCurrency + "");
		tv_num_add_full.setText(addHappyCurrency + "");
		tv_type_add_extra_full.setText(couponDesc);
		tv_num_add_extra_full.setText(couponAmount);
		tv_flag_type_add_extra_full.setText("￥");
		if ("0".equals(couponflag)) {
			rel_nofull.setVisibility(View.VISIBLE);
			rel_full.setVisibility(View.GONE);
		} else if ("1".equals(couponflag)) {
			rel_nofull.setVisibility(View.GONE);
			rel_full.setVisibility(View.VISIBLE);
			if ("加息券".equals(couponDesc)) {
				tv_flag_type_add_extra_full.setText("+");
			} else {
				tv_flag_type_add_extra_full.setText("￥");
			}
		}

		Dialog mDialog = new Dialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);

		tv_iknow.setOnClickListener(confirmListener);
		tv_rule.setOnClickListener(confirmListener);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.show();
		return mDialog;
	}

	public static Dialog signInSuccessDialog3(final Context ctx,
			int signInDays, int addHappyCurrency, final String appsignRuleUrl,
			OnClickListener mClickListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.signsuccessdialog3, null);
		// 下雨view
		RainView rain_dialog = (RainView) view.findViewById(R.id.rain_dialog);
		// 提示content
		RelativeLayout rel_tip_content = (RelativeLayout) view
				.findViewById(R.id.rel_tip_content);
		// 连续签到天数
		TextView num_day_signed = (TextView) view
				.findViewById(R.id.num_day_signed);
		// 获得快乐币个数
		TextView num_happybi_signed = (TextView) view
				.findViewById(R.id.num_happybi_signed);
		// 了解签到规则
		TextView tv_toRule = (TextView) view.findViewById(R.id.tv_toRule);
		// 设置数据
		num_day_signed.setText(signInDays + "");
		num_happybi_signed.setText(addHappyCurrency + "");
		rain_dialog.setView(rel_tip_content);
		final Dialog mDialog = new Dialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.setCancelable(false);
		rel_tip_content.setOnClickListener(mClickListener);
		tv_toRule.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (!TextUtils.isEmpty(appsignRuleUrl)) {
					Intent intent = new Intent(ctx, KKDWebActivity.class);
					intent.putExtra("titleName", "签到规则");
					intent.putExtra("url", appsignRuleUrl);
					ctx.startActivity(intent);
				}
			}
		});
		mDialog.show();
		return mDialog;
	}

	/**
	 * forTenderSupriseDialog:(这里用一句话描述这个方法的作用). <br/>
	 * 
	 * @author askzhao
	 * @param onCancelListener
	 * @param forTenderActivity
	 * @param i
	 * @param j
	 * @param object
	 * @return
	 */
	public static Dialog forTenderSupriseDialog(Context ctx, String url,
			final OnCancelListener onCancelListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.for_tender_suprise, null);
		RelativeLayout close_rl = (RelativeLayout) view
				.findViewById(R.id.close_rl);
		final Dialog mDialog = new Dialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);

		mDialog.setCanceledOnTouchOutside(true);
		close_rl.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				mDialog.dismiss();
			}
		});
		ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
		ImageLoader.getInstance().displayImage(url, imageView,
				new ImageLoadingListener() {

					@Override
					public void onLoadingStarted(String imageUri, View view) {
						// TODO Auto-generated method stub

					}

					@Override
					public void onLoadingFailed(String imageUri, View view,
							FailReason failReason) {
					}

					@Override
					public void onLoadingComplete(String imageUri, View view,
							Bitmap loadedImage) {
						// TODO Auto-generated method stub
						mDialog.show();
					}

					@Override
					public void onLoadingCancelled(String imageUri, View view) {
						// TODO Auto-generated method stub

					}
				});
		view.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				mDialog.dismiss();
				if (onCancelListener != null)
					onCancelListener.onCancel(mDialog);
			}
		});
		return mDialog;
	}

	public static Dialog signInSuccessDialog4(final Context ctx,
			int signInDays, int sumnum, String summaryFooter,
			final String appsignRuleUrl, String couponDesc,
			String couponAmount, int isRepairSigninStatus,
			List<String> dataList, OnClickListener mOnClickListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.bg_sign_dialog_new, null);
		final Dialog mDialog = new KKdDialog(ctx, R.style.TransparentDialog);
		List<Integer> dayList = SystemUtils.signDay(signInDays);
		// 关闭
		RelativeLayout close_img = (RelativeLayout) view
				.findViewById(R.id.close_img);
		RelativeLayout close_img1 = (RelativeLayout) view
				.findViewById(R.id.close_img1);
		// 下雨view
		RainView rain_dialog = (RainView) view.findViewById(R.id.rain_dialog);
		// 提示content
		LinearLayout rel_tip_content = (LinearLayout) view
				.findViewById(R.id.rel_tip_content);
		LinearLayout retroactive_ll = (LinearLayout) view
				.findViewById(R.id.retroactive_ll);
		if (isRepairSigninStatus == 0) { // 0不需要补签
			rain_dialog.setView(rel_tip_content);
			// 连续签到天数
			TextView num_day_signed = (TextView) view
					.findViewById(R.id.num_day_signed);
			// 获得快乐币个数
			TextView num_happybi_signed = (TextView) view
					.findViewById(R.id.num_happybi_signed);
			TextView tv_footer = (TextView) view.findViewById(R.id.tv_footer);
			// 了解签到规则
			LinearLayout linear_toRule = (LinearLayout) view
					.findViewById(R.id.linear_toRule);
			linear_toRule.setOnClickListener(new OnSingleClickListener() {

				@Override
				public void onSingleClick(View v) {
					Intent intent = new Intent(ctx, SignRuleActivity.class);
					ctx.startActivity(intent);
				}
			});
			// 优惠券奖励
			TextView get_tv1 = (TextView) view.findViewById(R.id.get_tv1);
			TextView get_tv2 = (TextView) view.findViewById(R.id.get_tv2);
			TextView plus_tv = (TextView) view.findViewById(R.id.plus_tv);
			TextView coupon_amount_tv = (TextView) view
					.findViewById(R.id.coupon_amount_tv);
			TextView coupon_type_tv = (TextView) view
					.findViewById(R.id.coupon_type_tv);
			if (TextUtils.isEmpty(couponDesc)) {
				get_tv1.setVisibility(View.GONE);
				get_tv2.setVisibility(View.VISIBLE);
				plus_tv.setVisibility(View.GONE);
				coupon_amount_tv.setVisibility(View.GONE);
				coupon_type_tv.setVisibility(View.GONE);
			} else {
				get_tv1.setVisibility(View.VISIBLE);
				get_tv2.setVisibility(View.GONE);
				plus_tv.setVisibility(View.VISIBLE);
				coupon_amount_tv.setVisibility(View.VISIBLE);
				coupon_amount_tv.setText(couponAmount);
				coupon_type_tv.setVisibility(View.VISIBLE);
				coupon_type_tv.setText(couponDesc);
			}
			// 进度
			LogUtil.e("TAG", "" + signInDays % 7);
			ImageView progress = (ImageView) view.findViewById(R.id.progress);
			if (signInDays % 7 == 0) {
				if (signInDays == 0) {
					progress.getLayoutParams().width = SystemUtils.dip2px(ctx,
							0);
				} else if (signInDays > 0) {
					progress.getLayoutParams().width = SystemUtils.dip2px(ctx,
							293);
				}
			} else if (signInDays % 7 == 1) {
				progress.getLayoutParams().width = SystemUtils.dip2px(ctx, 15);
			} else if (signInDays % 7 == 2) {
				progress.getLayoutParams().width = SystemUtils.dip2px(ctx, 61);
			} else if (signInDays % 7 == 3) {
				progress.getLayoutParams().width = SystemUtils.dip2px(ctx, 105);
			} else if (signInDays % 7 == 4) {
				progress.getLayoutParams().width = SystemUtils.dip2px(ctx, 150);
			} else if (signInDays % 7 == 5) {
				progress.getLayoutParams().width = SystemUtils.dip2px(ctx, 195);
			} else if (signInDays % 7 == 6) {
				progress.getLayoutParams().width = SystemUtils.dip2px(ctx, 241);
			}
			// 对应天数
			TextView one_day_tv = (TextView) view.findViewById(R.id.one_day_tv);
			TextView another_day_tv = (TextView) view
					.findViewById(R.id.another_day_tv);
			TextView three_day_tv = (TextView) view
					.findViewById(R.id.three_day_tv);
			TextView four_day_tv = (TextView) view
					.findViewById(R.id.four_day_tv);
			TextView five_day_tv = (TextView) view
					.findViewById(R.id.five_day_tv);
			TextView six_day_tv = (TextView) view.findViewById(R.id.six_day_tv);
			TextView seven_day_tv = (TextView) view
					.findViewById(R.id.seven_day_tv);
			List<TextView> daytvList = new ArrayList<TextView>();
			daytvList.add(one_day_tv);
			daytvList.add(another_day_tv);
			daytvList.add(three_day_tv);
			daytvList.add(four_day_tv);
			daytvList.add(five_day_tv);
			daytvList.add(six_day_tv);
			daytvList.add(seven_day_tv);
			if (signInDays % 7 != 0) {
				for (int colorId = 0; colorId < signInDays % 7; colorId++) {
					daytvList.get(colorId).setTextColor(
							Color.parseColor("#f95933"));
				}
			} else {
				if (signInDays != 0) {
					for (int colorId = 0; colorId < 7; colorId++) {
						daytvList.get(colorId).setTextColor(
								Color.parseColor("#f95933"));
					}
				}
			}

			for (int i = 0; i < dayList.size(); i++) {
				daytvList.get(i).setText(dayList.get(i) + "天");
			}
			// 当前签到位置
			ImageView posion_img1 = (ImageView) view
					.findViewById(R.id.posion_img1);
			ImageView posion_img2 = (ImageView) view
					.findViewById(R.id.posion_img2);
			ImageView posion_img3 = (ImageView) view
					.findViewById(R.id.posion_img3);
			ImageView posion_img4 = (ImageView) view
					.findViewById(R.id.posion_img4);
			ImageView posion_img5 = (ImageView) view
					.findViewById(R.id.posion_img5);
			ImageView posion_img6 = (ImageView) view
					.findViewById(R.id.posion_img6);
			ImageView posion_img7 = (ImageView) view
					.findViewById(R.id.posion_img7);
			List<ImageView> position_imgList = new ArrayList<ImageView>();
			position_imgList.add(posion_img1);
			position_imgList.add(posion_img2);
			position_imgList.add(posion_img3);
			position_imgList.add(posion_img4);
			position_imgList.add(posion_img5);
			position_imgList.add(posion_img6);
			position_imgList.add(posion_img7);
			if ((signInDays % 7) == 0) {
				if (signInDays != 0) {
					position_imgList.get(6).setVisibility(View.VISIBLE);
				}
			} else {
				position_imgList.get((signInDays % 7) - 1).setVisibility(
						View.VISIBLE);
			}
			// 设置数据
			num_day_signed.setText(signInDays + "");
			num_happybi_signed.setText(sumnum + "");
			tv_footer.setText(summaryFooter);

		} else if (isRepairSigninStatus == 1) { // 1需要
			rain_dialog.setView(retroactive_ll);
			/******** 补签窗口↓ **********/
			TextView day_signed = (TextView) view.findViewById(R.id.day_signed);
			day_signed.setText("" + signInDays);
			TextView happybi_signed = (TextView) view
					.findViewById(R.id.happybi_signed);
			happybi_signed.setText("" + sumnum);
			ImageView retroactive_progress = (ImageView) view
					.findViewById(R.id.retroactive_progress);
			if (signInDays % 7 == 0) {
				if (signInDays == 0) {
					retroactive_progress.getLayoutParams().width = SystemUtils
							.dip2px(ctx, 0);
				} else if (signInDays > 0) {
					retroactive_progress.getLayoutParams().width = SystemUtils
							.dip2px(ctx, 293);
				}
			} else if (signInDays % 7 == 1) {
				retroactive_progress.getLayoutParams().width = SystemUtils
						.dip2px(ctx, 15);
			} else if (signInDays % 7 == 2) {
				retroactive_progress.getLayoutParams().width = SystemUtils
						.dip2px(ctx, 61);
			} else if (signInDays % 7 == 3) {
				retroactive_progress.getLayoutParams().width = SystemUtils
						.dip2px(ctx, 105);
			} else if (signInDays % 7 == 4) {
				retroactive_progress.getLayoutParams().width = SystemUtils
						.dip2px(ctx, 150);
			} else if (signInDays % 7 == 5) {
				retroactive_progress.getLayoutParams().width = SystemUtils
						.dip2px(ctx, 195);
			} else if (signInDays % 7 == 6) {
				retroactive_progress.getLayoutParams().width = SystemUtils
						.dip2px(ctx, 241);
			}
			TextView retroactive_one_day_tv = (TextView) view
					.findViewById(R.id.retroactive_one_day_tv);
			TextView retroactive_another_day_tv = (TextView) view
					.findViewById(R.id.retroactive_another_day_tv);
			TextView retroactive_three_day_tv = (TextView) view
					.findViewById(R.id.retroactive_three_day_tv);
			TextView retroactive_four_day_tv = (TextView) view
					.findViewById(R.id.retroactive_four_day_tv);
			TextView retroactive_five_day_tv = (TextView) view
					.findViewById(R.id.retroactive_five_day_tv);
			TextView retroactive_six_day_tv = (TextView) view
					.findViewById(R.id.retroactive_six_day_tv);
			TextView retroactive_seven_day_tv = (TextView) view
					.findViewById(R.id.retroactive_seven_day_tv);
			List<TextView> retroactive_daytvList = new ArrayList<TextView>();
			retroactive_daytvList.add(retroactive_one_day_tv);
			retroactive_daytvList.add(retroactive_another_day_tv);
			retroactive_daytvList.add(retroactive_three_day_tv);
			retroactive_daytvList.add(retroactive_four_day_tv);
			retroactive_daytvList.add(retroactive_five_day_tv);
			retroactive_daytvList.add(retroactive_six_day_tv);
			retroactive_daytvList.add(retroactive_seven_day_tv);
			if (signInDays % 7 != 0) {
				for (int colorId = 0; colorId < signInDays % 7; colorId++) {
					retroactive_daytvList.get(colorId).setTextColor(
							Color.parseColor("#f95933"));
				}
			} else {
				if (signInDays != 0) {
					for (int colorId = 0; colorId < 7; colorId++) {
						retroactive_daytvList.get(colorId).setTextColor(
								Color.parseColor("#f95933"));
					}
				}
			}
			for (int i = 0; i < dayList.size(); i++) {
				retroactive_daytvList.get(i).setText(dayList.get(i) + "天");
			}
			// 当前签到位置
			ImageView retroactive_posion_img1 = (ImageView) view
					.findViewById(R.id.retroactive_posion_img1);
			ImageView retroactive_posion_img2 = (ImageView) view
					.findViewById(R.id.retroactive_posion_img2);
			ImageView retroactive_posion_img3 = (ImageView) view
					.findViewById(R.id.retroactive_posion_img3);
			ImageView retroactive_posion_img4 = (ImageView) view
					.findViewById(R.id.retroactive_posion_img4);
			ImageView retroactive_posion_img5 = (ImageView) view
					.findViewById(R.id.retroactive_posion_img5);
			ImageView retroactive_posion_img6 = (ImageView) view
					.findViewById(R.id.retroactive_posion_img6);
			ImageView retroactive_posion_img7 = (ImageView) view
					.findViewById(R.id.retroactive_posion_img7);
			List<ImageView> retroactive_position_imgList = new ArrayList<ImageView>();
			retroactive_position_imgList.add(retroactive_posion_img1);
			retroactive_position_imgList.add(retroactive_posion_img2);
			retroactive_position_imgList.add(retroactive_posion_img3);
			retroactive_position_imgList.add(retroactive_posion_img4);
			retroactive_position_imgList.add(retroactive_posion_img5);
			retroactive_position_imgList.add(retroactive_posion_img6);
			retroactive_position_imgList.add(retroactive_posion_img7);
			if ((signInDays % 7) == 0) {
				if (signInDays != 0) {
					retroactive_position_imgList.get(6).setVisibility(
							View.VISIBLE);
				}
			} else {
				retroactive_position_imgList.get((signInDays % 7) - 1)
						.setVisibility(View.VISIBLE);
			}
			TextView return_bt = (TextView) view.findViewById(R.id.return_bt);
			return_bt.setOnClickListener(new OnSingleClickListener() {

				@Override
				public void onSingleClick(View v) {
					Intent intent = new Intent(ctx, SignRuleActivity.class);
					ctx.startActivity(intent);
					if (mDialog != null) {
						mDialog.cancel();
					}
				}
			});
			TextView retroactive_bt = (TextView) view
					.findViewById(R.id.retroactive_bt);
			retroactive_bt.setOnClickListener(mOnClickListener);
			TextView hint_tv1 = (TextView) view.findViewById(R.id.hint_tv1);
			TextView hint_tv2 = (TextView) view.findViewById(R.id.hint_tv2);
			TextView hint_tv3 = (TextView) view.findViewById(R.id.hint_tv3);
			switch (dataList.size()) {
			case 0:
				hint_tv1.setText("");
				hint_tv2.setText("");
				hint_tv3.setText("");
				break;
			case 1:
				hint_tv1.setText(dataList.get(0));
				hint_tv2.setText("");
				hint_tv3.setText("");
				break;
			case 2:
				hint_tv1.setText(dataList.get(0));
				hint_tv2.setText(dataList.get(1));
				hint_tv3.setText("");
				break;
			case 3:
				hint_tv1.setText(dataList.get(0));
				hint_tv2.setText(dataList.get(1));
				hint_tv3.setText(dataList.get(2));
				break;
			}
			/******** 补签窗口↑ **********/

		}

		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		close_img1.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		close_img.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});

		mDialog.show();
		return mDialog;
	}

	/**************
	 * 我的定期弹窗
	 **************/
	public static Dialog myRegularDialog(Context context, String describe) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.myregular_dialog, null);
		TextView describe_tv = (TextView) view.findViewById(R.id.describe_tv);
		describe_tv.setText(describe);
		RelativeLayout close = (RelativeLayout) view.findViewById(R.id.close);
		final Dialog mDialog = new Dialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		close.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				mDialog.dismiss();
			}
		});
		return mDialog;
	}

	/*
	 * 分享dialog
	 */
	public static Dialog generateShareActDialog(final Context ctx,
			final ShareCallback nShareCallback) {

		ShareView view = new ShareView(ctx);

		final Dialog mAlertDialog = new KKdDialog(ctx,
				R.style.TransparentDialog);
		LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
				LayoutParams.WRAP_CONTENT);
		mAlertDialog.setContentView(view, params);
		mAlertDialog.setCanceledOnTouchOutside(true);
		view.setShareCallback(new ShareCallback() {

			@Override
			public void onShareToWxCycle() {
				// TODO Auto-generated method stub
				nShareCallback.onShareToWxCycle();
				mAlertDialog.cancel();
			}

			@Override
			public void onShareToWx() {
				// TODO Auto-generated method stub
				nShareCallback.onShareToWx();
				mAlertDialog.cancel();
			}

			@Override
			public void onShareToSina() {
				// TODO Auto-generated method stub
				nShareCallback.onShareToSina();
				mAlertDialog.cancel();
			}

			@Override
			public void onShareToQzone() {
				// TODO Auto-generated method stub
				nShareCallback.onShareToQzone();
				mAlertDialog.cancel();
			}

			@Override
			public void onShareToQQ() {
				// TODO Auto-generated method stub
				nShareCallback.onShareToQQ();
				mAlertDialog.cancel();
			}
		});
		view.findViewById(R.id.other).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				mAlertDialog.cancel();
			}
		});
		return mAlertDialog;
	}

	// 网银支付Dialog
	public static Dialog onlineBankingDialog(Context context, String url,
			String amount, OnClickListener mOnClickListener) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.onlinebankingdialog, null);
		RelativeLayout recharge_title_img = (RelativeLayout) view
				.findViewById(R.id.recharge_title_img);
		recharge_title_img.setOnClickListener(mOnClickListener);
		WebView webview = (WebView) view.findViewById(R.id.webview);
		WebSettings webSettings = webview.getSettings();
		// 设置WebView属性，能够执行Javascript脚本
		webSettings.setJavaScriptEnabled(true);
		webview.getSettings().setDefaultTextEncodingName("utf-8");
		// 设置可以访问文件
		webSettings.setAllowFileAccess(true);
		// 设置支持缩放
		webSettings.setBuiltInZoomControls(true);
		webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
		// 设置Web视图
		webview.setWebViewClient(new WebViewClient() {
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				if (url.startsWith("http:") || url.startsWith("https:")) {
					view.loadUrl(url);
				}
				return true;
			}

			@Override
			public void onReceivedError(WebView view, int errorCode,
					String description, String failingUrl) {
				super.onReceivedError(view, errorCode, description, failingUrl);
				// mWebView.loadUrl("file:///android_asset/rate.html");
			};

			public void onReceivedSslError(WebView view,
					SslErrorHandler handler, SslError error) {
				handler.proceed();
			}
		});
		String postdata = "amount=" + amount;
		webview.postUrl(url, postdata.getBytes());
		Dialog mDialog = new Dialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		return mDialog;
	}

	public static PopupWindow bubblePupopwindow(Context context, String content) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.bubblepupopwindow, null);
		TextView content_tv = (TextView) view.findViewById(R.id.content_tv);
		content_tv.setText(content);
		PopupWindow pw = new PopupWindow(view, LayoutParams.MATCH_PARENT,
				LayoutParams.WRAP_CONTENT);
		pw.setFocusable(true);
		pw.setOutsideTouchable(true);
		pw.setBackgroundDrawable(new BitmapDrawable());
		pw.setAnimationStyle(R.style.animationPreview);
		return pw;
	}

	public static PopupWindow bubblePupopwindow2(Context context,
			String content, float coordinate) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.bubblepupopwindow2, null);
		TextView content_tv = (TextView) view.findViewById(R.id.content_tv);
		content_tv.setText(content);
		RelativeLayout mrl = (RelativeLayout) view.findViewById(R.id.mrl);
		android.widget.RelativeLayout.LayoutParams params;
		if (coordinate == 11.0) {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 265), LayoutParams.WRAP_CONTENT);
			params.leftMargin = SystemUtils.dip2px(context, 55);
		} else if (coordinate == 12.0) {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 265), LayoutParams.WRAP_CONTENT);
			params.leftMargin = SystemUtils.dip2px(context, 70);
		} else if (coordinate == 16.0) {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 265), LayoutParams.WRAP_CONTENT);
			params.leftMargin = SystemUtils.dip2px(context, 60);
		} else if (coordinate == 6.0) {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 265), LayoutParams.WRAP_CONTENT);
			params.leftMargin = SystemUtils.dip2px(context, 75);
		} else if (coordinate == 10.0) {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 265), LayoutParams.WRAP_CONTENT);
			params.leftMargin = SystemUtils.dip2px(context, 43);
		} else {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 265), LayoutParams.WRAP_CONTENT);
			params.leftMargin = SystemUtils.dip2px(context, 70);
		}
		mrl.setLayoutParams(params);
		PopupWindow pw = new PopupWindow(view, LayoutParams.MATCH_PARENT,
				LayoutParams.WRAP_CONTENT);
		pw.setFocusable(true);
		pw.setOutsideTouchable(true);
		pw.setBackgroundDrawable(new BitmapDrawable());
		pw.setAnimationStyle(R.style.animationPreview);
		return pw;
	}

	public static PopupWindow bubblePupopwindow3(Context context,
			String content, float coordinate) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.bubblepupopwindow3, null);
		TextView content_tv = (TextView) view.findViewById(R.id.content_tv);
		content_tv.setText(content);
		RelativeLayout mrl = (RelativeLayout) view.findViewById(R.id.mrl);
		android.widget.RelativeLayout.LayoutParams params;
		if (coordinate == 11.0) {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 286), LayoutParams.WRAP_CONTENT);
			params.leftMargin = SystemUtils.dip2px(context, 55);
		} else if (coordinate == 12.0) {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 286), LayoutParams.WRAP_CONTENT);
			params.leftMargin = SystemUtils.dip2px(context, 30);
		} else if (coordinate == 16.0) {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 286), LayoutParams.WRAP_CONTENT);
			params.leftMargin = SystemUtils.dip2px(context, 45);
		} else if (coordinate == 6.0) {
			if (SystemUtils.getScreenWidth(context) == 540) {
				params = new android.widget.RelativeLayout.LayoutParams(
						SystemUtils.dip2px(context, 286),
						LayoutParams.WRAP_CONTENT);
				params.leftMargin = SystemUtils.dip2px(context, 30);
			} else {
				params = new android.widget.RelativeLayout.LayoutParams(
						SystemUtils.dip2px(context, 286),
						LayoutParams.WRAP_CONTENT);
				params.leftMargin = SystemUtils.dip2px(context, 0);
			}
		} else if (coordinate == 10.0) {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 286), LayoutParams.WRAP_CONTENT);
			params.leftMargin = SystemUtils.dip2px(context, 67);
		} else {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 286), LayoutParams.WRAP_CONTENT);
			params.leftMargin = SystemUtils.dip2px(context, 30);
		}
		mrl.setLayoutParams(params);
		PopupWindow pw = new PopupWindow(view, LayoutParams.MATCH_PARENT,
				LayoutParams.WRAP_CONTENT);
		pw.setFocusable(true);
		pw.setOutsideTouchable(true);
		pw.setBackgroundDrawable(new BitmapDrawable());
		pw.setAnimationStyle(R.style.animationPreview);
		return pw;
	}

	public static PopupWindow bubblePupopwindow4(Context context,
			String content, float coordinate) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.bubblepupopwindow4, null);
		TextView content_tv = (TextView) view.findViewById(R.id.content_tv);
		content_tv.setText(content);
		RelativeLayout mrl = (RelativeLayout) view.findViewById(R.id.mrl);
		android.widget.RelativeLayout.LayoutParams params;
		if (coordinate == 3.0) {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 286), LayoutParams.WRAP_CONTENT);
			if (SystemUtils.getScreenWidth(context) == 1080) {
				if (SystemUtils.getScreenHeight(context) == 1776) {
					params.leftMargin = SystemUtils.dip2px(context, 40);
				} else if (SystemUtils.getScreenHeight(context) == 1812) {
					params.leftMargin = SystemUtils.dip2px(context, 40);
				} else {
					params.leftMargin = SystemUtils.dip2px(context, 57);
				}
			} else {
				params.leftMargin = SystemUtils.dip2px(context, 40);
			}
		} else if (coordinate == 4.0) {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 286), LayoutParams.WRAP_CONTENT);
			params.leftMargin = SystemUtils.dip2px(context, 55);
		} else if (coordinate == 1.0) {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 286), LayoutParams.WRAP_CONTENT);
			if (SystemUtils.getScreenWidth(context) == 480) {
				params.leftMargin = SystemUtils.dip2px(context, 22);
			} else {
				params.leftMargin = SystemUtils.dip2px(context, 42);
			}
		} else {
			params = new android.widget.RelativeLayout.LayoutParams(
					SystemUtils.dip2px(context, 286), LayoutParams.WRAP_CONTENT);
			params.leftMargin = SystemUtils.dip2px(context, 40);
		}
		mrl.setLayoutParams(params);
		PopupWindow pw = new PopupWindow(view, LayoutParams.MATCH_PARENT,
				LayoutParams.WRAP_CONTENT);
		pw.setFocusable(true);
		pw.setOutsideTouchable(true);
		pw.setBackgroundDrawable(new BitmapDrawable());
		pw.setAnimationStyle(R.style.animationPreview);
		return pw;
	}

	public static RegularSelectorAdapter mRegularSelectorAdapter;

	public static Dialog generateSelectorDialog(Context context,
			AllConfig rAllConfig, final OnItemClickListener callback) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.bidtype_selector, null);
		final KKdDialog mDialog = new KKdDialog(context,
				R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);

		// 逻辑部分
		ListView listv = (ListView) view.findViewById(R.id.selector_list);
		if (mRegularSelectorAdapter == null)
			mRegularSelectorAdapter = new RegularSelectorAdapter(context,
					rAllConfig.getBidTypeArray().getNameArr());
		listv.setAdapter(mRegularSelectorAdapter);
		listv.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				callback.onItemClick(parent, view, position, id);
				mDialog.dismiss();
				mRegularSelectorAdapter.setCurPosition(position);
			}
		});
		view.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				mDialog.dismiss();
			}
		});

		mDialog.setOnShowListener(new OnShowListener() {

			@Override
			public void onShow(DialogInterface dialog) {
				// TODO Auto-generated method stub
				mRegularSelectorAdapter.notifyDataSetChanged();
			}
		});
		return mDialog;
	}

	/**
	 * 
	 * 红包Dialog
	 * 
	 */
	public static Dialog redPackageDialog(Context context,
			OnClickListener mOnClickListener) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.redpackagedialog, null);
		RelativeLayout remove = (RelativeLayout) view.findViewById(R.id.remove);
		final RelativeLayout remove_rl = (RelativeLayout) view
				.findViewById(R.id.remove_rl);
		RelativeLayout receive = (RelativeLayout) view
				.findViewById(R.id.receive);
		receive.setOnClickListener(mOnClickListener);
		final RelativeLayout receive_rl = (RelativeLayout) view
				.findViewById(R.id.receive_rl);
		RelativeLayout close = (RelativeLayout) view.findViewById(R.id.close);
		// 拆红包
		remove.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				remove_rl.setVisibility(View.GONE);
				receive_rl.setVisibility(View.VISIBLE);
			}
		});
		// 领取红包
		final KKdDialog mDialog = new KKdDialog(context,
				R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		close.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (mDialog != null) {
					mDialog.dismiss();
				}
			}
		});
		return mDialog;
	}

	/***
	 * 
	 * 设置个人昵称Dialog
	 * 
	 ***/
	public static PopupWindow setNickNameDialog(final Context context,
			String nickName, View parent, OnClickListener mOnClickListener) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.setnickname_dialog, null);
		// 取消
		TextView cancel_bt = (TextView) view.findViewById(R.id.cancel_bt);
		cancel_bt.setOnClickListener(mOnClickListener);
		// 确认
		final TextView confirm_bt = (TextView) view
				.findViewById(R.id.confirm_bt);
		confirm_bt.setOnClickListener(mOnClickListener);
		// 错误提示
		final TextView error_tv = (TextView) view.findViewById(R.id.error_tv);
		// 输入框
		final EditText nickname_et = (EditText) view
				.findViewById(R.id.nickname_et);
		nickname_et.setText(nickName);
		if (TextUtils.isEmpty(nickName)) {
			confirm_bt.setTextColor(Color.parseColor("#999999"));
			confirm_bt.setClickable(false);
		} else {
			confirm_bt.setTextColor(Color.parseColor("#5451b1"));
			confirm_bt.setClickable(true);
		}
		nickname_et.setSelection(nickname_et.getText().toString().length());
		nickname_et.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				int stLength = Tools.calculationStringLenght(s.toString());
				nickname_et.setTextColor(Color.parseColor("#333333"));
				error_tv.setText("");
				confirm_bt.setClickable(true);
				if (!TextUtils.isEmpty(s.toString())) {
					confirm_bt.setTextColor(Color.parseColor("#5451b1"));
				} else {
					confirm_bt.setTextColor(Color.parseColor("#999999"));
					confirm_bt.setClickable(false);
				}
				if (stLength > 16) {
					error_tv.setText("超出最多输入限制");
					nickname_et.setTextColor(Color.parseColor("#333333"));
					confirm_bt.setTextColor(Color.parseColor("#999999"));
					confirm_bt.setClickable(false);
				} else if (stLength > 0 && stLength <= 16) {
					if (!Tools.judgeStringQualified(s.toString())) {
						error_tv.setText("昵称只能由数字、英文、中文、下划线组成");
						nickname_et.setTextColor(Color.parseColor("#333333"));
						confirm_bt.setTextColor(Color.parseColor("#999999"));
						confirm_bt.setClickable(false);
					} else {
						confirm_bt.setClickable(true);
					}
				}
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {

			}

			@Override
			public void afterTextChanged(Editable s) {

			}
		});

		PopupWindow mPopupWindow = new PopupWindow(view,
				WindowManager.LayoutParams.FILL_PARENT,
				WindowManager.LayoutParams.FILL_PARENT, true);
		mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
		mPopupWindow.setOutsideTouchable(true);
		mPopupWindow
				.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
		RelativeLayout popupwidow_ll = (RelativeLayout) view
				.findViewById(R.id.popupwidow_ll);
		return mPopupWindow;
	}

	// 完成新手任务或者首投后的弹窗
	public static Dialog finishXinshouShoutouDialog(Context context,
			String imageUrl, OnSingleClickListener mClickListener) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.finish_xinshou_shoutou_dialog, null);
		View rel_close = view.findViewById(R.id.rel_close);
		ImageView iv = (ImageView) view.findViewById(R.id.iv);
		View tv = view.findViewById(R.id.tv);
		ImageLoader.getInstance().displayImage(imageUrl, iv);
		final KKdDialog mDialog = new KKdDialog(context,
				R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		rel_close.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		tv.setOnClickListener(mClickListener);
		return mDialog;
	}

	// 首页的红包弹窗
	public static Dialog redPackage2Dialog(final Context context,
			String imageUrl) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.redpackage_xinshou_homepage_dailog, null);
		View rel_close = view.findViewById(R.id.rel_close);
		ImageView iv_redpackage_detail = (ImageView) view
				.findViewById(R.id.iv_redpackage_detail);
		final TextView tv_toRegister = (TextView) view
				.findViewById(R.id.tv_toRegister);
		final TextView tv_toLogin = (TextView) view
				.findViewById(R.id.tv_toLogin);
		final View rel_container = view.findViewById(R.id.rel_container);
		final RelativeLayout rel_content_1 = (RelativeLayout) view
				.findViewById(R.id.rel_content_1);
		final ImageView iv_gai = (ImageView) view.findViewById(R.id.iv_gai);
		final ImageView iv_open = (ImageView) view.findViewById(R.id.iv_open);
		if (!TextUtils.isEmpty(imageUrl)) {
			ImageLoader.getInstance().displayImage(imageUrl,
					iv_redpackage_detail);
		}
		tv_toRegister.setEnabled(false);
		tv_toLogin.setEnabled(false);
		final KKdDialog mDialog = new KKdDialog(context,
				R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		rel_close.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		iv_open.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				iv_open.setEnabled(false);
				AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
				alphaAnimation.setDuration(500);
				alphaAnimation.setFillAfter(true);
				rel_content_1.startAnimation(alphaAnimation);
				AnimationSet animationSet = new AnimationSet(true);
				animationSet.addAnimation(alphaAnimation);
				ScaleAnimation scaleAnimation = new ScaleAnimation(1, 1.3f, 1,
						1.3f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
						ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
				scaleAnimation.setDuration(500);
				animationSet.addAnimation(scaleAnimation);
				animationSet.setFillAfter(true);
				iv_open.startAnimation(animationSet);

				MyAnimation animation = new MyAnimation();
				animation.setFillAfter(true);
				iv_gai.startAnimation(animation);

				animationSet.setAnimationListener(new AnimationListener() {

					@Override
					public void onAnimationStart(Animation animation) {

					}

					@Override
					public void onAnimationRepeat(Animation animation) {

					}

					@Override
					public void onAnimationEnd(Animation animation) {
						rel_container.setVisibility(View.GONE);
						tv_toRegister.setEnabled(true);
						tv_toLogin.setEnabled(true);
					}
				});
			}
		});
		tv_toRegister.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
				Intent intent = new Intent(context, RegisterActivity.class);
				context.startActivity(intent);
			}
		});
		tv_toLogin.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
				Intent intent = new Intent(context, LoginActivity.class);
				context.startActivity(intent);
			}
		});
		return mDialog;
	}

	// 注册成功后的弹窗
	public static Dialog registerSuccessDialog(final Context context,
			String imageUrl) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.register_success_dialog, null);
		View rel_close = view.findViewById(R.id.rel_close);
		ImageView iv = (ImageView) view.findViewById(R.id.iv);
		View tv_close_register_success = view
				.findViewById(R.id.tv_close_register_success);
		TextView tv = (TextView) view.findViewById(R.id.tv);
		if (!TextUtils.isEmpty(imageUrl)) {
			ImageLoader.getInstance().displayImage(imageUrl, iv);
		}
		final KKdDialog mDialog = new KKdDialog(context,
				R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		rel_close.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		tv_close_register_success
				.setOnClickListener(new OnSingleClickListener() {

					@Override
					public void onSingleClick(View v) {
						if (mDialog != null) {
							mDialog.cancel();
						}
					}
				});
		tv.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		mDialog.setOnCancelListener(new OnCancelListener() {

			@Override
			public void onCancel(DialogInterface dialog) {
				AppUtil.makeToastForCustomer(context, "您尚未开通存管账户\n请先开通");
			}
		});
		return mDialog;
	}

	// 完成首充后的弹窗
	public static Dialog finishFirstRechargeDialog(final Context context,
			String title, String num, String couponCount,
			OnSingleClickListener mClickListener) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.finish_first_recharge_dailog, null);
		View rel_close = view.findViewById(R.id.rel_close);
		ImageView iv = (ImageView) view.findViewById(R.id.iv);
		View tv = view.findViewById(R.id.tv);
		TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
		TextView tv_num = (TextView) view.findViewById(R.id.tv_num);
		TextView tv_count = (TextView) view.findViewById(R.id.tv_count);
		tv_title.setText("恭喜您获得首充红包");
		if (!TextUtils.isEmpty(num)) {
			tv_num.setText(num);
		}
		tv_count.setText("×" + couponCount);
		final KKdDialog mDialog = new KKdDialog(context,
				R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.setCancelable(false);
		// rel_close.setOnClickListener(new OnSingleClickListener() {
		//
		// @Override
		// public void onSingleClick(View v) {
		// if (mDialog != null) {
		// mDialog.cancel();
		// }
		// }
		// });
		tv.setOnClickListener(mClickListener);
		return mDialog;
	}

	// 提示去设置头像的弹窗
	public static Dialog toSetHeadDialog(Context context, String imageUrl) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.tosethead_dialog, null);
		View rel_close = view.findViewById(R.id.rel_close);
		ImageView iv = (ImageView) view.findViewById(R.id.iv);
		TextView tv = (TextView) view.findViewById(R.id.tv);
		ImageLoader.getInstance().displayImage(imageUrl, iv);
		final KKdDialog mDialog = new KKdDialog(context,
				R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		rel_close.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		tv.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		mDialog.show();
		return mDialog;
	}

	/******************
	 * 我的界面 特权Dialog
	 ******************/
	public static Dialog privilegeDialog(Context context, List<Privilege> arrs,
			int position, OnClickListener mOnClickListener,
			OnViewPagerItemListener callback) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.privilege_dialog, null);
		// 关闭按钮
		RelativeLayout close_img = (RelativeLayout) view
				.findViewById(R.id.close_img);
		close_img.setOnClickListener(mOnClickListener);
		// viewPager
		CycleViewPager viewPager = (CycleViewPager) view
				.findViewById(R.id.viewpager_dialog);
		viewPager.setPageMargin(SystemUtils.dip2px(context, 100));
		PrivilegeViewPagerAdapter adapter = new PrivilegeViewPagerAdapter(
				context, arrs);
		viewPager.setAdapter(adapter);
		viewPager.setCurrentItem(position);
		adapter.setOnViewPagerItemListener(callback);
		KKdDialog mDialog = new KKdDialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		return mDialog;
	}

	public static Dialog finishFirstRechargeDialog2(Context context) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.finish_first_recharge_dailog2, null);
		View rel_close = view.findViewById(R.id.rel_close);
		final View rel_container = view.findViewById(R.id.rel_container);
		final RelativeLayout rel_content_1 = (RelativeLayout) view
				.findViewById(R.id.rel_content_1);
		final ImageView iv_gai = (ImageView) view.findViewById(R.id.iv_gai);
		final ImageView iv_open = (ImageView) view.findViewById(R.id.iv_open);
		final View tv = view.findViewById(R.id.tv);
		tv.setEnabled(false);
		final KKdDialog mDialog = new KKdDialog(context,
				R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		rel_close.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		tv.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		iv_open.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				iv_open.setEnabled(false);
				AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
				alphaAnimation.setDuration(500);
				alphaAnimation.setFillAfter(true);
				rel_content_1.startAnimation(alphaAnimation);
				AnimationSet animationSet = new AnimationSet(true);
				animationSet.addAnimation(alphaAnimation);
				ScaleAnimation scaleAnimation = new ScaleAnimation(1, 1.3f, 1,
						1.3f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
						ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
				scaleAnimation.setDuration(500);
				animationSet.addAnimation(scaleAnimation);
				animationSet.setFillAfter(true);
				iv_open.startAnimation(animationSet);

				MyAnimation animation = new MyAnimation();
				animation.setFillAfter(true);
				iv_gai.startAnimation(animation);

				animationSet.setAnimationListener(new AnimationListener() {

					@Override
					public void onAnimationStart(Animation animation) {

					}

					@Override
					public void onAnimationRepeat(Animation animation) {

					}

					@Override
					public void onAnimationEnd(Animation animation) {
						rel_container.setVisibility(View.GONE);
						tv.setEnabled(true);
					}
				});
			}
		});
		mDialog.show();

		return mDialog;
	}

	/*****
	 * 公用Dialog
	 *****/
	public static Dialog communalDialog(Context context,
			OnClickListener callback) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.communaldialog_layout, null);
		TextView cancel_tv_bt = (TextView) view.findViewById(R.id.cancel_tv_bt);
		cancel_tv_bt.setOnClickListener(callback);
		TextView re_share_bt = (TextView) view.findViewById(R.id.re_share_bt);
		re_share_bt.setOnClickListener(callback);
		KKdDialog mDialog = new KKdDialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		return mDialog;
	}

	/*****
	 * 公用Dialog
	 *****/
	public static Dialog communalDialog1(Context context,
			OnClickListener callback) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.communaldialog_layout1, null);
		TextView re_share_bt = (TextView) view.findViewById(R.id.re_share_bt);
		re_share_bt.setOnClickListener(callback);
		KKdDialog mDialog = new KKdDialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		return mDialog;
	}

	public static Dialog communalDialog1(Context context, String content,
			String sure, OnClickListener callback) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.communaldialog_layout1, null);
		TextView tv_content = (TextView) view.findViewById(R.id.tv_content);
		TextView re_share_bt = (TextView) view.findViewById(R.id.re_share_bt);
		tv_content.setText(content);
		re_share_bt.setText(sure);
		re_share_bt.setOnClickListener(callback);
		KKdDialog mDialog = new KKdDialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		return mDialog;
	}

	/*************
	 * 签到页补签弹窗
	 ************/
	public static Dialog retroactiveDialog(Context context, int coinCount,
			List<String> dataList, String reSignExt,
			OnClickListener mOnClickListener) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.retroactivedialog_layout, null);
		// 补签花费快乐币个数
		TextView retroactive_coin = (TextView) view
				.findViewById(R.id.retroactive_coin);
		retroactive_coin.setText(coinCount + "");
		// 提示语
		TextView hint_tv1 = (TextView) view.findViewById(R.id.hint_tv1);
		TextView hint_tv2 = (TextView) view.findViewById(R.id.hint_tv2);
		TextView hint_tv3 = (TextView) view.findViewById(R.id.hint_tv3);
		TextView desc_tv = (TextView) view.findViewById(R.id.desc_tv);
		desc_tv.setText(reSignExt);
		if (dataList != null) {
			switch (dataList.size()) {
			case 0:
				hint_tv1.setText("");
				hint_tv2.setText("");
				hint_tv3.setText("");
				break;
			case 1:
				hint_tv1.setText(dataList.get(0));
				hint_tv2.setText("");
				hint_tv3.setText("");
				break;
			case 2:
				hint_tv1.setText(dataList.get(0));
				hint_tv2.setText(dataList.get(1));
				hint_tv3.setText("");
				break;
			case 3:
				hint_tv1.setText(dataList.get(0));
				hint_tv2.setText(dataList.get(1));
				hint_tv3.setText(dataList.get(2));
				break;
			}
		}

		// Xbutton
		RelativeLayout close_img = (RelativeLayout) view
				.findViewById(R.id.close_img);
		close_img.setOnClickListener(mOnClickListener);
		// 还是算了
		TextView return_bt = (TextView) view.findViewById(R.id.return_bt);
		return_bt.setOnClickListener(mOnClickListener);
		// 补签 Button
		TextView retroactive_bt = (TextView) view
				.findViewById(R.id.retroactive_bt);
		retroactive_bt.setOnClickListener(mOnClickListener);
		KKdDialog mDialog = new KKdDialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		return mDialog;
	}

	/**********************
	 * 快乐币任务完成进度Dialog
	 **********************/
	static ObjectAnimator animator = null;
	static ObjectAnimator rlanimator = null;

	public static Dialog happyCoinCompleteProgressDialog(
			final Activity context, boolean signFlg, final int signInStatus,
			int signInCionSum, long signIncouponAmount, int signDays,
			final int type, int inviteCionSum, final int inviteStatus,
			final int poiStatus, int poiCionSum, int poiMoreCionSum,
			final String inviteStrategyUrl, int doubleAllSum, int customerSeat,
			int doubleSum, String doubleRate, int doubleMisSum,
			final String coinMisUrl, int isRepairSigninStatus) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.happycoincompleteprogressdialog_layout, null);
		final RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.rl);
		// 只有签到时快乐币任务窗口才有下雨动画
		RainView mRainView = (RainView) view.findViewById(R.id.rain_dialog);
		if (signFlg) {
			mRainView.setVisibility(View.VISIBLE);
			rl.setVisibility(View.GONE);
			mRainView.setView(rl);
		} else {
			mRainView.setVisibility(View.GONE);
			rl.setVisibility(View.VISIBLE);
		}

		// 规则
		RelativeLayout rule_bt = (RelativeLayout) view
				.findViewById(R.id.rule_bt);
		// 快乐币任务全部完成获取快乐币总数
		TextView allsum_tv = (TextView) view.findViewById(R.id.allsum_tv);
		allsum_tv.setText("" + doubleAllSum);
		// 完成快乐币任务排名
		TextView ranking_tv = (TextView) view.findViewById(R.id.ranking_tv);
		ranking_tv.setText("" + customerSeat);
		// 完成任务获得快乐币个数
		TextView happy_sum_tv = (TextView) view.findViewById(R.id.happy_sum_tv);
		happy_sum_tv.setText(doubleMisSum + "个");
		// 完成快乐币任务翻倍的倍率
		TextView rate_tv = (TextView) view.findViewById(R.id.rate_tv);
		rate_tv.setText(doubleRate);
		// 翻倍获取快乐币个数
		TextView missum_tv = (TextView) view.findViewById(R.id.missum_tv);
		missum_tv.setText(doubleSum + "个");
		// 邀请好友获得快乐币个数
		TextView getappycoin_desc = (TextView) view
				.findViewById(R.id.getappycoin_desc);
		TextView getappycoin_tv = (TextView) view
				.findViewById(R.id.getappycoin_tv);
		// 整个窗体
		final LinearLayout whole_rl = (LinearLayout) view
				.findViewById(R.id.whole_rl);
		// 完成整个窗体
		final RelativeLayout completed_whole_ll = (RelativeLayout) view
				.findViewById(R.id.completed_whole_ll);
		// 旋转按钮
		final ImageView flip_img = (ImageView) view.findViewById(R.id.flip_img);
		// 关闭按钮
		final ImageView close_image = (ImageView) view
				.findViewById(R.id.close_image);
		// 关闭
		RelativeLayout close_img = (RelativeLayout) view
				.findViewById(R.id.close_img);
		RelativeLayout complete_close_bt = (RelativeLayout) view
				.findViewById(R.id.complete_close_bt);
		// close_img.setOnClickListener(mOnClickListener);
		// 签到任务完成图标
		final ImageView sign_complete_icon = (ImageView) view
				.findViewById(R.id.sign_complete_icon);
		// 邀请好友任务完成图标
		final ImageView happy_invitation_icon = (ImageView) view
				.findViewById(R.id.happy_invitation_icon);
		// 投资任务完成图标
		final ImageView happy_investment_icon = (ImageView) view
				.findViewById(R.id.happy_investment_icon);
		// 签到任务未完成图标
		TextView sign_complete_tv = (TextView) view
				.findViewById(R.id.sign_complete_tv);
		// 邀请好友任务未完成图标
		TextView happy_invitation_tv = (TextView) view
				.findViewById(R.id.happy_invitation_tv);
		// 投资任务未完成图标
		TextView happy_investment_tv = (TextView) view
				.findViewById(R.id.happy_investment_tv);
		// 邀请好友完成与未完成状态设置
		if (inviteStatus == 0) {
			getappycoin_desc.setText("成功分享邀请攻略即可");
			getappycoin_tv.setText("");
			happy_invitation_icon.setVisibility(View.GONE);
			happy_invitation_tv.setVisibility(View.VISIBLE);
		} else if (inviteStatus == 1) {
			getappycoin_desc.setText("获得");
			getappycoin_tv.setText(inviteCionSum + "个快乐币");
			happy_invitation_icon.setVisibility(View.VISIBLE);
			happy_invitation_tv.setVisibility(View.GONE);
		}
		// 签到完成状态，0未完成，1完成；
		TextView getsign_tv1 = (TextView) view.findViewById(R.id.getsign_tv1);
		TextView getsign_tv2 = (TextView) view.findViewById(R.id.getsign_tv2);
		TextView getsign_tv3 = (TextView) view.findViewById(R.id.getsign_tv3);
		if (signInStatus == 0) {
			getsign_tv1.setText("根据签到规则奖励");
			getsign_tv2.setText("");
			getsign_tv3.setText("");
			sign_complete_icon.setVisibility(View.GONE);
			sign_complete_tv.setVisibility(View.VISIBLE);
		} else if (signInStatus == 1) {
			if (isRepairSigninStatus == 0) { // 0：不可以补签
				getsign_tv1.setText("连续签到" + signDays + "天");
			} else if (isRepairSigninStatus == 1) { // 1：可以补签
				getsign_tv1.setText("连续签到" + signDays + "天,可补签");
			}
			getsign_tv2.setText("获得");
			if (signIncouponAmount == 0) {
				getsign_tv3.setText(signInCionSum + "个快乐币");
			} else if (signIncouponAmount != 0) {
				getsign_tv3.setText(signInCionSum + "个快乐币+"
						+ signIncouponAmount / 100 + "元优惠券");
			}
			sign_complete_icon.setVisibility(View.VISIBLE);
			sign_complete_tv.setVisibility(View.GONE);
		}
		// 投资完成状态，0未完成，1完成；
		TextView getpoi_tv1 = (TextView) view.findViewById(R.id.getpoi_tv1);
		TextView getpoi_tv2 = (TextView) view.findViewById(R.id.getpoi_tv2);
		TextView getpoi_tv3 = (TextView) view.findViewById(R.id.getpoi_tv3);
		if (poiStatus == 0) {
			getpoi_tv1.setText("最高");
			getpoi_tv2.setText(poiMoreCionSum + "个快乐币");
			getpoi_tv3.setText("投资越多奖励越多");
			happy_investment_icon.setVisibility(View.GONE);
			happy_investment_tv.setVisibility(View.VISIBLE);
		} else if (poiStatus == 1) {
			getpoi_tv1.setText("获得");
			getpoi_tv2.setText(poiCionSum + "个快乐币");
			happy_investment_icon.setVisibility(View.VISIBLE);
			happy_investment_tv.setVisibility(View.GONE);
		}
		if (inviteStatus == 1 && signInStatus == 1 && poiStatus == 1) {
			close_image.setVisibility(View.GONE);
			flip_img.setVisibility(View.VISIBLE);
		} else {
			close_image.setVisibility(View.VISIBLE);
			flip_img.setVisibility(View.GONE);
		}

		if (signFlg) {
			mRainView.setStopAnimation(new StopAnimation() {

				@Override
				public void stop(boolean stopFlg) {
					if (stopFlg) {
						// 盖章动画
						PropertyValuesHolder rlpvhY = PropertyValuesHolder
								.ofFloat("scaleX", 1f, 0.9f, 1f);
						PropertyValuesHolder rlpvhZ = PropertyValuesHolder
								.ofFloat("scaleY", 1f, 0.9f, 1f);
						rlanimator = ObjectAnimator.ofPropertyValuesHolder(
								whole_rl, rlpvhY, rlpvhZ);
						rlanimator.setDuration(500);
						PropertyValuesHolder pvhX = PropertyValuesHolder
								.ofFloat("alpha", 0f, 1f);
						PropertyValuesHolder pvhY = PropertyValuesHolder
								.ofFloat("scaleX", 3f, 1f);
						PropertyValuesHolder pvhZ = PropertyValuesHolder
								.ofFloat("scaleY", 3f, 1f);
						// type: 1当前完成的是签到任务，2当前完成的是邀请好友任务，3当前完成的是投资任务
						if (type == 1) {
							animator = ObjectAnimator.ofPropertyValuesHolder(
									sign_complete_icon, pvhX, pvhY, pvhZ);
						} else if (type == 2) {
							animator = ObjectAnimator.ofPropertyValuesHolder(
									happy_invitation_icon, pvhX, pvhY, pvhZ);
						} else if (type == 3) {
							animator = ObjectAnimator.ofPropertyValuesHolder(
									happy_investment_icon, pvhX, pvhY, pvhZ);
						}
						animator.setDuration(500);
						animator.addListener(new AnimatorListener() {

							@Override
							public void onAnimationStart(Animator animation) {

							}

							@Override
							public void onAnimationRepeat(Animator animation) {

							}

							@Override
							public void onAnimationEnd(Animator animation) {
								rlanimator.start();
							}

							@Override
							public void onAnimationCancel(Animator animation) {

							}
						});
						// 　打开窗口动画
						PropertyValuesHolder wholealpha = PropertyValuesHolder
								.ofFloat("alpha", 0f, 1f);
						PropertyValuesHolder wholepvhY = PropertyValuesHolder
								.ofFloat("scaleX", 3f, 1f);
						PropertyValuesHolder wholepvhZ = PropertyValuesHolder
								.ofFloat("scaleY", 3f, 1f);
						final ObjectAnimator wholeanimator = ObjectAnimator
								.ofPropertyValuesHolder(rl, wholepvhY,
										wholepvhZ, wholealpha);
						wholeanimator.setDuration(100);
						wholeanimator.start();
						wholeanimator.addListener(new AnimatorListener() {

							@Override
							public void onAnimationStart(Animator animation) {

							}

							@Override
							public void onAnimationRepeat(Animator animation) {

							}

							@Override
							public void onAnimationEnd(Animator animation) {
								animator.start();
							}

							@Override
							public void onAnimationCancel(Animator animation) {

							}
						});
					}
				}
			});
		} else {
			// 盖章动画
			PropertyValuesHolder rlpvhY = PropertyValuesHolder.ofFloat(
					"scaleX", 1f, 0.9f, 1f);
			PropertyValuesHolder rlpvhZ = PropertyValuesHolder.ofFloat(
					"scaleY", 1f, 0.9f, 1f);
			rlanimator = ObjectAnimator.ofPropertyValuesHolder(whole_rl,
					rlpvhY, rlpvhZ);
			rlanimator.setDuration(500);
			PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("alpha",
					0f, 1f);
			PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("scaleX",
					3f, 1f);
			PropertyValuesHolder pvhZ = PropertyValuesHolder.ofFloat("scaleY",
					3f, 1f);
			// type: 1当前完成的是签到任务，2当前完成的是邀请好友任务，3当前完成的是投资任务
			if (type == 1) {
				animator = ObjectAnimator.ofPropertyValuesHolder(
						sign_complete_icon, pvhX, pvhY, pvhZ);
			} else if (type == 2) {
				animator = ObjectAnimator.ofPropertyValuesHolder(
						happy_invitation_icon, pvhX, pvhY, pvhZ);
			} else if (type == 3) {
				animator = ObjectAnimator.ofPropertyValuesHolder(
						happy_investment_icon, pvhX, pvhY, pvhZ);
			}
			animator.setDuration(500);
			animator.addListener(new AnimatorListener() {

				@Override
				public void onAnimationStart(Animator animation) {

				}

				@Override
				public void onAnimationRepeat(Animator animation) {

				}

				@Override
				public void onAnimationEnd(Animator animation) {
					rlanimator.start();
				}

				@Override
				public void onAnimationCancel(Animator animation) {

				}
			});
			// 　打开窗口动画
			PropertyValuesHolder wholealpha = PropertyValuesHolder.ofFloat(
					"alpha", 0f, 1f);
			PropertyValuesHolder wholepvhY = PropertyValuesHolder.ofFloat(
					"scaleX", 3f, 1f);
			PropertyValuesHolder wholepvhZ = PropertyValuesHolder.ofFloat(
					"scaleY", 3f, 1f);
			final ObjectAnimator wholeanimator = ObjectAnimator
					.ofPropertyValuesHolder(rl, wholepvhY, wholepvhZ,
							wholealpha);
			wholeanimator.setDuration(100);
			wholeanimator.start();
			wholeanimator.addListener(new AnimatorListener() {

				@Override
				public void onAnimationStart(Animator animation) {

				}

				@Override
				public void onAnimationRepeat(Animator animation) {

				}

				@Override
				public void onAnimationEnd(Animator animation) {
					animator.start();
				}

				@Override
				public void onAnimationCancel(Animator animation) {

				}
			});
		}

		// 旋转动画
		final ObjectAnimator scale = ObjectAnimator.ofFloat(whole_rl, "scaleX",
				1.0F, 0F);
		scale.setDuration(500);
		final ObjectAnimator lscale = ObjectAnimator.ofFloat(
				completed_whole_ll, "scaleX", 0.0F, 1.0F);
		lscale.setDuration(1000);

		scale.addListener(new AnimatorListener() {

			@Override
			public void onAnimationStart(Animator animation) {

			}

			@Override
			public void onAnimationRepeat(Animator animation) {

			}

			@Override
			public void onAnimationEnd(Animator animation) {
				whole_rl.setVisibility(View.GONE);
				flip_img.setVisibility(View.GONE);
				close_image.setVisibility(View.VISIBLE);
				completed_whole_ll.setVisibility(View.VISIBLE);
				lscale.start();
			}

			@Override
			public void onAnimationCancel(Animator animation) {

			}
		});
		final KKdDialog mDialog = new KKdDialog(context,
				R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		mDialog.setOnCancelListener(new OnCancelListener() {

			@Override
			public void onCancel(DialogInterface dialog) {
				if (animator != null) {
					animator.cancel();
				}
				if (rlanimator != null) {
					rlanimator.cancel();
				}
				if (scale != null) {
					scale.cancel();
				}
				if (lscale != null) {
					lscale.cancel();
				}
			}
		});
		close_img.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (inviteStatus == 1 && signInStatus == 1 && poiStatus == 1) {
					scale.start();
				} else {
					if (mDialog != null) {
						mDialog.dismiss();
						mDialog.cancel();
					}
				}
			}
		});
		complete_close_bt.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (mDialog != null) {
					mDialog.dismiss();
					mDialog.cancel();
				}
			}
		});
		mDialog.setOnKeyListener(new OnKeyListener() {

			@Override
			public boolean onKey(DialogInterface dialog, int keyCode,
					KeyEvent event) {
				return true;
			}
		});
		// 规则
		if (!TextUtils.isEmpty(coinMisUrl)) {
			rule_bt.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					if (!TextUtils.isEmpty(coinMisUrl)) {
						Intent intent = new Intent(context,
								KKDWebActivity.class);
						intent.putExtra("url", coinMisUrl);
						intent.putExtra("titleName", "快乐币任务提醒");
						context.startActivity(intent);
					}
					if (mDialog != null) {
						mDialog.dismiss();
						mDialog.cancel();
					}
				}
			});
		}

		// 签到任务
		RelativeLayout signInTask = (RelativeLayout) view
				.findViewById(R.id.signInTask);
		signInTask.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(context, HomeActivity.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				context.startActivity(intent);
				NotifyDispatcher.getInstance().sendNotify("",
						Const.NOTIFY_HOME_SIGN);
				context.finish();
			}
		});
		signInTask.setClickable(true);
		if (signInStatus == 1) { // 签到任务完成以后不可点击
			signInTask.setClickable(false);
		}
		// 邀请要有任务
		RelativeLayout inviteFriendsToWork = (RelativeLayout) view
				.findViewById(R.id.inviteFriendsToWork);
		inviteFriendsToWork.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				SystemUtils.onEvent("Discovery_InviteFrinds_Strategy", 1);
				if (inviteStrategyUrl != null) {
					Intent intent = new Intent(context, KKDWebActivity.class);
					intent.putExtra("url", inviteStrategyUrl);
					intent.putExtra("titleName", "快乐币任务提醒");
					context.startActivity(intent);
					if (mDialog != null) {
						mDialog.dismiss();
						mDialog.cancel();
					}
				}
			}
		});
		inviteFriendsToWork.setClickable(true);
		if (inviteStatus == 1) { // 邀请好友任务完成以后不可点击
			inviteFriendsToWork.setClickable(false);
		}
		// 投资任务
		RelativeLayout investmentTask = (RelativeLayout) view
				.findViewById(R.id.investmentTask);
		investmentTask.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(context, SelectedBidActivity.class);
				intent.putExtra("group_name", "定期宝");
				context.startActivity(intent);
				if (mDialog != null) {
					mDialog.dismiss();
					mDialog.cancel();
				}
			}
		});
		investmentTask.setClickable(true);
		if (poiStatus == 1) {
			investmentTask.setClickable(false);
		}
		return mDialog;
	}

	// 版本更新Dialog
	public static Dialog updateEdition(Context context, String imgUrl,
			String versionDesc, int mustUpdateStatus, String appVersion,
			OnClickListener mOnClickListener) {
		View view = ((LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.update_editon, null);
		// 关闭
		RelativeLayout cancel_deletebank = (RelativeLayout) view
				.findViewById(R.id.cancel_deletebank);
		cancel_deletebank.setOnClickListener(mOnClickListener);
		Button confirm_deletebank = (Button) view
				.findViewById(R.id.confirm_deletebank);
		confirm_deletebank.setOnClickListener(mOnClickListener);
		ImageView img = (ImageView) view.findViewById(R.id.img);
		// ImageLoader.getInstance().displayImage(imgUrl, img,
		// R.drawable.update_title_bg);
		TextView versionDesc_tv = (TextView) view
				.findViewById(R.id.versionDesc);
		versionDesc_tv.setText(versionDesc);
		if (mustUpdateStatus == 0) {
			cancel_deletebank.setVisibility(View.VISIBLE);
		} else if (mustUpdateStatus == 1) {
			cancel_deletebank.setVisibility(View.GONE);
		}
		// 最新版本号
		TextView currentversion = (TextView) view
				.findViewById(R.id.currentversion);
		currentversion.setText("V" + appVersion);
		KKdDialog mDialog = new KKdDialog(context, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		return mDialog;
	}

	/********************************
	 * 版本更新对话框
	 ********************************/
	public static Dialog updateDialog(final Context ctx, String versionDesc,
			int mustUpdateStatus, final String appVersion,
			OnClickListener mOnClickListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.item_update_dialog, null);
		// 关闭
		View close = view.findViewById(R.id.close);
		// 版本号
		TextView tv = (TextView) view.findViewById(R.id.tv);
		// 版本描述
		TextView tv_versionDesc = (TextView) view
				.findViewById(R.id.tv_versionDesc);
		tv.setText(appVersion);
		tv_versionDesc.setText(versionDesc);
		// 是否强制更新
		if (mustUpdateStatus == 0) {
			close.setVisibility(View.VISIBLE);
		} else if (mustUpdateStatus == 1) {
			close.setVisibility(View.GONE);
		}
		final Dialog mDialog = new KKdDialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.setCancelable(false);
		// 关闭
		close.setOnClickListener(mOnClickListener);
		// 立即升级
		view.findViewById(R.id.bottom_toUpdate).setOnClickListener(
				mOnClickListener);
		return mDialog;
	}

	// 账户余额委托扣款Dialog
	public Dialog principalChargeDialog(Context ctx) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.principalchargedialog_layout, null);
		TextView open_bt = (TextView) view.findViewById(R.id.open_bt);
		final KKdDialog mDialog = new KKdDialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.setCancelable(false);
		open_bt.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (mDialog != null) {
					mDialog.dismiss();
					mDialog.cancel();
				}
			}
		});
		return mDialog;
	}

	// 下载pdf文档提示Dialog
	public static Dialog pdfDownLoadDialog(final Context ctx, String path) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.pdf_download_dialog, null);

		final KKdDialog mDialog = new KKdDialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.setCancelable(false);
		TextView download_dir_tv = (TextView) view
				.findViewById(R.id.download_dir_tv);
		download_dir_tv.setText("路径: " + path);
		Button open_file = (Button) view.findViewById(R.id.open_file);
		open_file.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (mDialog != null) {
					mDialog.dismiss();
					mDialog.cancel();
				}
				Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
				intent.setDataAndType(
						Uri.parse("file://" + FileUtils.getKKDRootPath()
								+ "pdf/"), "*/*");
				intent.addCategory(Intent.CATEGORY_OPENABLE);
				ctx.startActivity(intent);
			}
		});
		Button i_known = (Button) view.findViewById(R.id.i_known);
		i_known.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (mDialog != null) {
					mDialog.dismiss();
					mDialog.cancel();
				}
			}
		});
		return mDialog;
	}

	/**
	 * 双向选择dialog
	 * 
	 * @param ctx
	 * @param title
	 * @param mOnClickListener
	 * @return
	 */
	public static Dialog twoSelectDialog(final Context ctx, String title,
			OnClickListener mOnClickListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.item_twoselect_dialog, null);
		View close = view.findViewById(R.id.close);
		TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
		View cancel = view.findViewById(R.id.tv_cancel);
		View sure = view.findViewById(R.id.tv_sure);
		tv_title.setText(title);
		final Dialog mDialog = new Dialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		mDialog.setCancelable(true);
		close.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		cancel.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		sure.setOnClickListener(mOnClickListener);
		return mDialog;
	}

	// 第一次进入K计划详情Dialog
	public static Dialog oneFinancialParticularsDialog(Context ctx, int imgID1,
			int imgID2) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.onefinancialparticularsdialog_layout, null);
		final ImageView close_img = (ImageView) view
				.findViewById(R.id.close_img);
		close_img.setVisibility(View.GONE);
		ArrayList<HomeRecommend> list_active = new ArrayList<HomeRecommend>();
		HomeRecommend mHomeRecommend1 = new HomeRecommend();
		mHomeRecommend1.setImageId(imgID1);
		HomeRecommend mHomeRecommend2 = new HomeRecommend();
		mHomeRecommend2.setImageId(imgID2);
		list_active.add(mHomeRecommend1);
		list_active.add(mHomeRecommend2);
		CycleBannerView cycle_banner_view = (CycleBannerView) view
				.findViewById(R.id.cycle_banner_view);
		cycle_banner_view.setImages(list_active)
				.setImageLoader(new LBannerImgLoader()).isAutoPlay(false)
				.setBannerAnimation(Transformer.ZoomOutSlide).start()
				.setOnPageChangeListener(new OnPageChangeListener() {

					@Override
					public void onPageSelected(int arg0) {
						LogUtil.e("TAG", "onPageSelected----->" + arg0);
						if (arg0 == 1) {
							close_img.setVisibility(View.GONE);
						} else if (arg0 == 2) {
							close_img.setVisibility(View.VISIBLE);
						}

					}

					@Override
					public void onPageScrolled(int arg0, float arg1, int arg2) {
						// TODO Auto-generated method stub

					}

					@Override
					public void onPageScrollStateChanged(int arg0) {

					}
				});
		final KKdDialog mDialog = new KKdDialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		close_img.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				mDialog.dismiss();
			}
		});
		return mDialog;
	}

	/**
	 * 
	 * 解绑银行卡失败弹窗
	 * 
	 * @param ctx
	 * @return
	 */
	public static Dialog deleteBankCardFail(final Context ctx) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.item_dialog_deletebank_fail, null);
		View close = view.findViewById(R.id.close);
		View cancel = view.findViewById(R.id.tv_cancel);
		View sure = view.findViewById(R.id.tv_sure);
		final Dialog mDialog = new Dialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(false);
		mDialog.setCancelable(true);
		cancel.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		sure.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				ctx.startActivity(new Intent(ctx, HomeActivity.class));
				HomeActivity.mActivity.walletNavigation();
				if (mDialog != null) {
					mDialog.cancel();
				}
				((Activity) ctx).finish();
			}
		});
		return mDialog;
	}

	public static Dialog callService(final Context ctx) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.item_callservice_dialog, null);
		View close = view.findViewById(R.id.close);
		View tv_cancel = view.findViewById(R.id.tv_cancel);
		View tv_sure = view.findViewById(R.id.tv_sure);
		final Dialog mDialog = new KKdDialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		mDialog.setCancelable(true);
		close.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		tv_cancel.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		tv_sure.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				Intent intent = new Intent(Intent.ACTION_CALL, Uri
						.parse("tel:4000137000"));
				ctx.startActivity(intent);
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		return mDialog;
	}

	/**
	 * 撤回债权对话框
	 * 
	 * @param ctx
	 * @param shengyu
	 * @param benxi
	 * @param mClickListener
	 * @return
	 */
	public static Dialog cancelDebt(final Context ctx, String shengyu,
			String benxi, OnClickListener mClickListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.item_canceldebt_dialog, null);
		View close = view.findViewById(R.id.close);
		View tv_cancel = view.findViewById(R.id.tv_cancel);
		View tv_sure = view.findViewById(R.id.tv_sure);
		// 当前剩余
		TextView tv_shengyu = (TextView) view.findViewById(R.id.tv_shengyu);
		// 待收本息
		TextView tv_benxi = (TextView) view.findViewById(R.id.tv_benxi);
		final Dialog mDialog = new KKdDialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		mDialog.setCancelable(true);
		tv_shengyu.setText(shengyu);
		tv_benxi.setText(benxi);
		close.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		tv_cancel.setOnClickListener(new OnSingleClickListener() {

			@Override
			public void onSingleClick(View v) {
				if (mDialog != null) {
					mDialog.cancel();
				}
			}
		});
		tv_sure.setOnClickListener(mClickListener);
		return mDialog;
	}

	/**
	 * 
	 * 撤回债权成功对话框
	 * 
	 * @param ctx
	 * @param titleName
	 * @param mClickListener
	 * @return
	 */
	public static Dialog cancelDebtSuccess(final Context ctx, String titleName,
			OnClickListener mClickListener) {
		View view = ((LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.item_success_canceldebt_dialog, null);
		View close = view.findViewById(R.id.close);
		View tv_sure = view.findViewById(R.id.tv_sure);
		TextView tv_titlename = (TextView) view.findViewById(R.id.tv_titlename);
		final Dialog mDialog = new KKdDialog(ctx, R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		mDialog.setCancelable(true);
		tv_titlename.setText(titleName);
		close.setOnClickListener(mClickListener);
		tv_sure.setOnClickListener(mClickListener);
		return mDialog;
	}

	/**
	 * 弹出气泡提示popupwindow
	 * 
	 * @param mContext
	 * @param targetView
	 * @param desc
	 * @return
	 */
	@SuppressLint("NewApi")
	public static PopupWindow showTipPopupWindow(Context mContext,
			View targetView, String desc) {
		View view = ((LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.bubble_popupwindow, null);
		final ImageView horn = (ImageView) view.findViewById(R.id.horn);
		final ImageView horn_bottom = (ImageView) view
				.findViewById(R.id.horn_bottom);
		final View content = view.findViewById(R.id.content);
		TextView content_tv = (TextView) view.findViewById(R.id.content_tv);
		if (!TextUtils.isEmpty(desc)) {
			content_tv.setText(desc);
		}
		PopupWindow pw = new PopupWindow(view, LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT);
		pw.setFocusable(true);
		pw.setOutsideTouchable(true);
		pw.setBackgroundDrawable(new BitmapDrawable());
		pw.setAnimationStyle(R.style.animationPreview);
		pw.showAsDropDown(targetView, -targetView.getWidth(), 0);

		horn.measure(ViewGroup.LayoutParams.WRAP_CONTENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		final int width_horn = horn.getMeasuredWidth();
		int[] location = new int[2];
		targetView.getLocationOnScreen(location);
		final int targetMid = location[0] + targetView.getWidth() / 2;
		final int y = location[1];
		mHandler.postDelayed(new Runnable() {

			@Override
			public void run() {
				int[] location = new int[2];
				content.getLocationOnScreen(location);
				int chazhi = targetMid - location[0] - width_horn / 2;
				android.widget.RelativeLayout.LayoutParams params = new android.widget.RelativeLayout.LayoutParams(
						android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT,
						android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
				params.leftMargin = chazhi;
				if (location[1] < y) {
					params.topMargin = content.getHeight();
					horn_bottom.setLayoutParams(params);
					horn_bottom.setRotation(180);
					horn.setVisibility(View.GONE);
					horn_bottom.setVisibility(View.VISIBLE);
				} else {
					horn.setLayoutParams(params);
					horn.setVisibility(View.VISIBLE);
					horn_bottom.setVisibility(View.GONE);
				}
			}
		}, 0);
		return pw;
	}

	/****
	 * 成功通用Dialog
	 */
	public static Dialog buySuccessDialog(Context mContext, int resultImg,
			String resultStr, String cancelStr, String confirmStr,
			OnClickListener mOnClick) {
		View view = ((LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.buysuccessdialog, null);
		// 结果图标
		ImageView result_img = (ImageView) view.findViewById(R.id.result_img);
		result_img.setImageResource(resultImg);
		// 结果提示语
		TextView result_tv = (TextView) view.findViewById(R.id.result_tv);
		result_tv.setText(resultStr);
		// 取消
		TextView cancel_bt = (TextView) view.findViewById(R.id.cancel_bt);
		cancel_bt.setText(cancelStr);
		cancel_bt.setOnClickListener(mOnClick);
		// 确认
		TextView confirm_bt = (TextView) view.findViewById(R.id.confirm_bt);
		confirm_bt.setText(confirmStr);
		confirm_bt.setOnClickListener(mOnClick);
		final Dialog mDialog = new KKdDialog(mContext,
				R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		mDialog.setCancelable(true);
		return mDialog;
	}

	// 通用提示Dialog
	public static Dialog generalHintDialog(Context mContext, String messageStr,
			String messageColor, String cancleStr, String cancleColor,
			String confirmStr, String confirmColor,
			OnClickListener mOnClickListener) {
		View view = ((LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.alert_dialog_2button, null);
		TextView dialog_message = (TextView) view
				.findViewById(R.id.dialog_message);
		dialog_message.setText(messageStr);
		dialog_message.setTextColor(Color.parseColor(messageColor));
		TextView cancle = (TextView) view.findViewById(R.id.cancle);
		cancle.setText(cancleStr);
		cancle.setTextColor(Color.parseColor(cancleColor));
		TextView confirm = (TextView) view.findViewById(R.id.confirm);
		confirm.setText(confirmStr);
		confirm.setTextColor(Color.parseColor(confirmColor));
		cancle.setOnClickListener(mOnClickListener);
		confirm.setOnClickListener(mOnClickListener);
		final Dialog mDialog = new KKdDialog(mContext,
				R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		mDialog.setCancelable(true);
		return mDialog;
	}

	// 风险评估完成Dilog
	public static Dialog evaluationOnDialog(Context mContext, String number,
			OnClickListener mOnClickListener) {
		View view = ((LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.evaluationondialog, null);
		// 知道了
		TextView gotit_bt = (TextView) view.findViewById(R.id.gotit_bt);
		// 　关闭
		RelativeLayout close_bt = (RelativeLayout) view
				.findViewById(R.id.close_bt);
		// 奖励快乐币个数
		TextView number_tv = (TextView) view.findViewById(R.id.number_tv);
		LinearLayout number_rl = (LinearLayout) view
				.findViewById(R.id.number_rl);
		if ("0".equals(number)) {
			number_rl.setVisibility(View.GONE);
		} else {
			number_tv.setText(number);
		}
		gotit_bt.setOnClickListener(mOnClickListener);
		close_bt.setOnClickListener(mOnClickListener);
		final Dialog mDialog = new KKdDialog(mContext,
				R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		mDialog.setCancelable(true);
		return mDialog;
	}

	// 账户页风险评估入口弹窗
	public static Dialog assessmentDialog(Context mContext, String type,
			OnClickListener mOnClickListener) {
		View view = ((LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
				R.layout.assessment_dialog, null);

		RelativeLayout close_bt = (RelativeLayout) view
				.findViewById(R.id.close_bt);
		Button asses_bt = (Button) view.findViewById(R.id.asses_bt);
		final Dialog mDialog = new KKdDialog(mContext,
				R.style.TransparentDialog);
		mDialog.setContentView(view);
		mDialog.setCanceledOnTouchOutside(true);
		mDialog.setCancelable(true);
		asses_bt.setOnClickListener(mOnClickListener);
		close_bt.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				mDialog.dismiss();
			}
		});
		return mDialog;
	}
}
